/**
 * Get a count of the total topics on the site.
 *
 * @return int $count Total topic count.
 */
function bp_forums_total_topic_count()
{
    global $bbdb;
    /** This action is documented in bp-forums/bp-forums-screens */
    do_action('bbpress_init');
    if (isset($bbdb)) {
        if (bp_is_active('groups')) {
            $groups_table_sql = groups_add_forum_tables_sql();
            $groups_where_sql = groups_add_forum_where_sql("t.topic_status = 0");
        } else {
            $groups_table_sql = '';
            $groups_where_sql = "t.topic_status = 0";
        }
        $count = $bbdb->get_results("SELECT t.topic_id FROM {$bbdb->topics} AS t {$groups_table_sql} WHERE {$groups_where_sql}");
        $count = count((array) $count);
    } else {
        $count = 0;
    }
    /**
     * Filters the total topic count for the site.
     *
     * @since BuddyPress (1.5.0)
     *
     * @param int $count Total topic count.
     */
    return apply_filters('bp_forums_total_topic_count', $count);
}
Example #2
0
function bp_forums_total_topic_count()
{
    global $bbdb;
    do_action('bbpress_init');
    if (isset($bbdb)) {
        if (bp_is_active('groups')) {
            $groups_table_sql = groups_add_forum_tables_sql();
            $groups_where_sql = groups_add_forum_where_sql("t.topic_status = 0");
        } else {
            $groups_table_sql = '';
            $groups_where_sql = "t.topic_status = 0";
        }
        $count = $bbdb->get_results("SELECT t.topic_id FROM {$bbdb->topics} AS t {$groups_table_sql} WHERE {$groups_where_sql}");
        $count = count((array) $count);
    } else {
        $count = 0;
    }
    return apply_filters('bp_forums_total_topic_count', $count);
}