예제 #1
0
/**
 * Return a fancy description of the current forum, including total
 * topics, total replies, and last activity.
 *
 * @since bbPress (r2860)
 *
 * @param mixed $args This function supports these arguments:
 *  - forum_id: Forum id
 *  - before: Before the text
 *  - after: After the text
 *  - size: Size of the avatar
 * @uses bbp_get_forum_id() To get the forum id
 * @uses bbp_get_forum_topic_count() To get the forum topic count
 * @uses bbp_get_forum_reply_count() To get the forum reply count
 * @uses bbp_get_forum_subforum_count() To get the forum subforum count
 * @uses bbp_get_forum_freshness_link() To get the forum freshness link
 * @uses bbp_get_forum_last_active_id() To get the forum last active id
 * @uses bbp_get_author_link() To get the author link
 * @uses add_filter() To add the 'view all' filter back
 * @uses apply_filters() Calls 'bbp_get_single_forum_description' with
 *                        the description and args
 * @return string Filtered forum description
 */
function bbp_get_single_forum_description($args = '')
{
    // Default arguments
    $defaults = array('forum_id' => 0, 'before' => '<div class="bbp-template-notice info"><p class="bbp-forum-description">', 'after' => '</p></div>', 'size' => 14, 'feed' => true);
    $r = bbp_parse_args($args, $defaults, 'get_single_forum_description');
    extract($r);
    // Validate forum_id
    $forum_id = bbp_get_forum_id($forum_id);
    // Unhook the 'view all' query var adder
    remove_filter('bbp_get_forum_permalink', 'bbp_add_view_all');
    // Get some forum data
    $topic_count = bbp_get_forum_topic_count($forum_id);
    $reply_count = bbp_get_forum_reply_count($forum_id);
    $last_active = bbp_get_forum_last_active_id($forum_id);
    // Has replies
    if (!empty($reply_count)) {
        $reply_text = sprintf(_n('%s reply', '%s replies', $reply_count, 'bbpress'), $reply_count);
    }
    // Forum has active data
    if (!empty($last_active)) {
        $topic_text = bbp_get_forum_topics_link($forum_id);
        $time_since = bbp_get_forum_freshness_link($forum_id);
        $last_updated_by = bbp_get_author_link(array('post_id' => $last_active, 'size' => $size));
        // Forum has no last active data
    } else {
        $topic_text = sprintf(_n('%s topic', '%s topics', $topic_count, 'bbpress'), $topic_count);
    }
    // Forum has active data
    if (!empty($last_active)) {
        if (!empty($reply_count)) {
            if (bbp_is_forum_category($forum_id)) {
                $retstr = sprintf(__('This category contains %1$s and %2$s, and was last updated by %3$s %4$s.', 'bbpress'), $topic_text, $reply_text, $last_updated_by, $time_since);
            } else {
                $retstr = sprintf(__('This forum contains %1$s and %2$s, and was last updated by %3$s %4$s.', 'bbpress'), $topic_text, $reply_text, $last_updated_by, $time_since);
            }
        } else {
            if (bbp_is_forum_category($forum_id)) {
                $retstr = sprintf(__('This category contains %1$s, and was last updated by %2$s %3$s.', 'bbpress'), $topic_text, $last_updated_by, $time_since);
            } else {
                $retstr = sprintf(__('This forum contains %1$s, and was last updated by %2$s %3$s.', 'bbpress'), $topic_text, $last_updated_by, $time_since);
            }
        }
        // Forum has no last active data
    } else {
        if (!empty($reply_count)) {
            if (bbp_is_forum_category($forum_id)) {
                $retstr = sprintf(__('This category contains %1$s and %2$s.', 'bbpress'), $topic_text, $reply_text);
            } else {
                $retstr = sprintf(__('This forum contains %1$s and %2$s.', 'bbpress'), $topic_text, $reply_text);
            }
        } else {
            if (!empty($topic_count)) {
                if (bbp_is_forum_category($forum_id)) {
                    $retstr = sprintf(__('This category contains %1$s.', 'bbpress'), $topic_text);
                } else {
                    $retstr = sprintf(__('This forum contains %1$s.', 'bbpress'), $topic_text);
                }
            } else {
                $retstr = __('This forum is empty.', 'bbpress');
            }
        }
    }
    // Add feeds
    //$feed_links = ( !empty( $feed ) ) ? bbp_get_forum_topics_feed_link ( $forum_id ) . bbp_get_forum_replies_feed_link( $forum_id ) : '';
    // Add the 'view all' filter back
    add_filter('bbp_get_forum_permalink', 'bbp_add_view_all');
    // Combine the elements together
    $retstr = $before . $retstr . $after;
    // Return filtered result
    return apply_filters('bbp_get_single_forum_description', $retstr, $args);
}
예제 #2
0
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 
}
예제 #3
0
파일: forum.php 프로젝트: joeyblake/bbpress
 /**
  * @covers ::bbp_get_forum_freshness_link
  */
 public function test_bbp_get_forum_freshness_link_with_unpublished_replies()
 {
     if (is_multisite()) {
         $this->markTestSkipped('Skipping URL tests in multiste for now.');
     }
     $now = time();
     $post_date_t1 = date('Y-m-d H:i:s', $now - 60 * 60 * 18);
     // 18 hours ago
     $post_date_t2 = date('Y-m-d H:i:s', $now - 60 * 60 * 16);
     // 16 hours ago
     $post_date_t3 = date('Y-m-d H:i:s', $now - 60 * 60 * 14);
     // 14 hours ago
     $post_date_t4 = date('Y-m-d H:i:s', $now - 60 * 60 * 12);
     // 12 hours ago
     $post_date_t5 = date('Y-m-d H:i:s', $now - 60 * 60 * 10);
     // 1o hours ago
     $f = $this->factory->forum->create();
     $link = bbp_get_forum_freshness_link($f);
     $this->assertSame('No Topics', $link);
     $t1 = $this->factory->topic->create(array('post_title' => 'Topic 1', 'post_parent' => $f, 'post_date' => $post_date_t1, 'topic_meta' => array('forum_id' => $f)));
     $link = bbp_get_forum_freshness_link($f);
     $this->assertSame('<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-1" title="Topic 1">18 hours ago</a>', $link);
     $t2 = $this->factory->topic->create(array('post_title' => 'Topic 2', 'post_parent' => $f, 'post_date' => $post_date_t2, 'topic_meta' => array('forum_id' => $f)));
     $link = bbp_get_forum_freshness_link($f);
     $this->assertSame('<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-2" title="Topic 2">16 hours ago</a>', $link);
     bbp_spam_topic($t2);
     $link = bbp_get_forum_freshness_link($f);
     $this->assertSame('<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-1" title="Topic 1">18 hours ago</a>', $link);
     $t3 = $this->factory->topic->create(array('post_title' => 'Topic 3', 'post_parent' => $f, 'post_date' => $post_date_t3, 'topic_meta' => array('forum_id' => $f)));
     $link = bbp_get_forum_freshness_link($f);
     $this->assertSame('<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-3" title="Topic 3">14 hours ago</a>', $link);
     // Todo: Use bbp_trash_topic() and not wp_trash_post()
     wp_trash_post($t3);
     $link = bbp_get_forum_freshness_link($f);
     $this->assertSame('<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-1" title="Topic 1">18 hours ago</a>', $link);
     $t4 = $this->factory->topic->create(array('post_title' => 'Topic 4', 'post_parent' => $f, 'post_date' => $post_date_t4, 'topic_meta' => array('forum_id' => $f)));
     $link = bbp_get_forum_freshness_link($f);
     $this->assertSame('<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-4" title="Topic 4">12 hours ago</a>', $link);
     bbp_unapprove_topic($t4);
     $link = bbp_get_forum_freshness_link($f);
     $this->assertSame('<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-1" title="Topic 1">18 hours ago</a>', $link);
     bbp_unspam_topic($t2);
     $link = bbp_get_forum_freshness_link($f);
     $this->assertSame('<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-2" title="Topic 2">16 hours ago</a>', $link);
     // Todo: Use bbp_untrash_topic() and not wp_untrash_post()
     wp_untrash_post($t3);
     $link = bbp_get_forum_freshness_link($f);
     $this->assertSame('<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-3" title="Topic 3">14 hours ago</a>', $link);
     bbp_approve_topic($t4);
     $link = bbp_get_forum_freshness_link($f);
     $this->assertSame('<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-4" title="Topic 4">12 hours ago</a>', $link);
     $t5 = $this->factory->topic->create(array('post_title' => 'Topic 5', 'post_parent' => $f, 'post_date' => $post_date_t5, 'topic_meta' => array('forum_id' => $f)));
     $link = bbp_get_forum_freshness_link($f);
     $this->assertSame('<a href="http://' . WP_TESTS_DOMAIN . '/?topic=topic-5" title="Topic 5">10 hours ago</a>', $link);
 }
예제 #4
0
 function wm_bbp_post_custom_metas($empty, $meta, $args)
 {
     //Requirements check
     if (!in_array($meta, array('forum-update', 'forum-replies', 'forum-topics'))) {
         return $empty;
     }
     //Helper variables
     $meta_output = $output = $title = '';
     if ('forum-update' === $meta) {
         $title = __('Last update', 'mustang');
         $meta_output = bbp_get_forum_freshness_link($args['post_id']);
     } elseif ('forum-topics' === $meta) {
         $title = __('Topics count', 'mustang');
         $meta_output = bbp_get_forum_topic_count($args['post_id']);
     } elseif ('forum-replies' === $meta) {
         $title = __('Replies count', 'mustang');
         $meta_output = bbp_get_forum_reply_count($args['post_id']);
     }
     //Add new meta
     $replacements = array('{attributes}' => ' title="' . $title . '"', '{class}' => 'entry-' . $meta . ' entry-meta-element', '{content}' => $meta_output);
     $replacements = apply_filters('wmhook_wm_bbp_post_custom_metas_replacements_' . $meta, $replacements);
     if (isset($args['html_custom'][$meta])) {
         $output .= strtr($args['html_custom'][$meta], $replacements);
     } else {
         $output .= strtr($args['html'], $replacements);
     }
     //Output
     return apply_filters('wmhook_wm_bbp_post_custom_metas_output', $empty . $output, $meta);
 }
예제 #5
0
/**
 * Return a fancy description of the current forum, including total
 * topics, total replies, and last activity.
 *
 * @since Boss 1.0.0
 *
 * @param mixed $args This function supports these arguments:
 *  - forum_id: Forum id
 *  - before: Before the text
 *  - after: After the text
 *  - size: Size of the avatar
 * @uses bbp_get_forum_id() To get the forum id
 * @uses bbp_get_forum_topic_count() To get the forum topic count
 * @uses bbp_get_forum_reply_count() To get the forum reply count
 * @uses bbp_get_forum_freshness_link() To get the forum freshness link
 * @uses bbp_get_forum_last_active_id() To get the forum last active id
 * @uses bbp_get_author_link() To get the author link
 * @uses add_filter() To add the 'view all' filter back
 * @uses apply_filters() Calls 'bbp_get_single_forum_description' with
 *                        the description and args
 * @return string Filtered forum description
 */
function buddyboss_bbp_get_single_forum_description($args = '')
{
    // Parse arguments against default values
    $r = bbp_parse_args($args, array('forum_id' => 0, 'before' => '<div class="bbp-template-notice info"><p class="bbp-forum-description">', 'after' => '</p></div>', 'size' => 14, 'feed' => true), 'get_single_forum_description');
    // Validate forum_id
    $forum_id = bbp_get_forum_id($r['forum_id']);
    // Unhook the 'view all' query var adder
    remove_filter('bbp_get_forum_permalink', 'bbp_add_view_all');
    // Get some forum data
    $tc_int = bbp_get_forum_topic_count($forum_id, false);
    $rc_int = bbp_get_forum_reply_count($forum_id, false);
    $topic_count = bbp_get_forum_topic_count($forum_id);
    $reply_count = bbp_get_forum_reply_count($forum_id);
    $last_active = bbp_get_forum_last_active_id($forum_id);
    // Has replies
    if (!empty($reply_count)) {
        $reply_text = sprintf(_n('%s reply', '%s replies', $rc_int, 'boss'), $reply_count);
    }
    // Forum has active data
    if (!empty($last_active)) {
        $topic_text = bbp_get_forum_topics_link($forum_id);
        $time_since = bbp_get_forum_freshness_link($forum_id);
        $last_updated_by = bbp_get_author_link(array('post_id' => $last_active, 'size' => $r['size']));
        // Forum has no last active data
    } else {
        $topic_text = sprintf(_n('%s topic', '%s topics', $tc_int, 'boss'), $topic_count);
    }
    // Forum has active data
    if (!empty($last_active)) {
        if (!empty($reply_count)) {
            if (bbp_is_forum_category($forum_id)) {
                $retstr = sprintf(__('<span class="post-num">%1$s and %2$s</span> <span class="last-activity">Last updated by %3$s %4$s</span>', 'boss'), $topic_text, $reply_text, $last_updated_by, $time_since);
            } else {
                $retstr = sprintf(__('<span class="post-num">%1$s and %2$s</span> <span class="last-activity">Last updated by %3$s %4$s<span>', 'boss'), $topic_text, $reply_text, $last_updated_by, $time_since);
            }
        } else {
            if (bbp_is_forum_category($forum_id)) {
                $retstr = sprintf(__('<span class="post-num">%1$s</span> <span class="last-activity">Last updated by %2$s %3$s</span>', 'boss'), $topic_text, $last_updated_by, $time_since);
            } else {
                $retstr = sprintf(__('<span class="post-num">%1$s</span> <span class="last-activity">Last updated by %2$s %3$s</span>', 'boss'), $topic_text, $last_updated_by, $time_since);
            }
        }
        // Forum has no last active data
    } else {
        if (!empty($reply_count)) {
            if (bbp_is_forum_category($forum_id)) {
                $retstr = sprintf(__('<span class="post-num">%1$s and %2$s</span>', 'boss'), $topic_text, $reply_text);
            } else {
                $retstr = sprintf(__('<span class="post-num">%1$s and %2$s</span>', 'boss'), $topic_text, $reply_text);
            }
        } else {
            if (!empty($topic_count)) {
                if (bbp_is_forum_category($forum_id)) {
                    $retstr = sprintf(__('<span class="post-num">%1$s</span>', 'boss'), $topic_text);
                } else {
                    $retstr = sprintf(__('<span class="post-num">%1$s</span>', 'boss'), $topic_text);
                }
            } else {
                $retstr = __('<span class="post-num">0 topics and 0 posts</span>', 'boss');
            }
        }
    }
    // Add feeds
    //$feed_links = ( !empty( $r['feed'] ) ) ? bbp_get_forum_topics_feed_link ( $forum_id ) . bbp_get_forum_replies_feed_link( $forum_id ) : '';
    // Add the 'view all' filter back
    add_filter('bbp_get_forum_permalink', 'bbp_add_view_all');
    // Combine the elements together
    $retstr = $r['before'] . $retstr . $r['after'];
    // Return filtered result
    return apply_filters('bbp_get_single_forum_description', $retstr, $r);
}
?>
</li>

	<li class="bbp-forum-freshness">

		<p class="bbp-topic-meta">

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

			<span class="bbp-topic-freshness-author">
			
				<?php 
if ($has_replies = strstr(bbp_get_forum_freshness_link(), '<a')) {
    ?>
					
					<?php 
    _ex('by ', 'bbPress Freshness Author', 'bunyad');
    ?>
					<?php 
    bbp_author_link(array('post_id' => bbp_get_forum_last_active_id(), 'size' => 45));
    ?>
</span>
					
				<?php 
}
?>

			<?php