function bp_get_group_forum_post_count($args = '') { global $groups_template; $defaults = array('showtext' => false); $r = wp_parse_args($args, $defaults); extract($r, EXTR_SKIP); if (!($forum_id = groups_get_groupmeta($groups_template->group->id, 'forum_id'))) { return false; } if (!bp_is_active('forums')) { return false; } if (!$groups_template->group->forum_counts) { $groups_template->group->forum_counts = bp_forums_get_forum_topicpost_count((int) $forum_id); } if ((bool) $showtext) { if (1 == (int) $groups_template->group->forum_counts[0]->posts) { $total_posts = sprintf(__('%d post', 'buddypress'), (int) $groups_template->group->forum_counts[0]->posts); } else { $total_posts = sprintf(__('%d posts', 'buddypress'), (int) $groups_template->group->forum_counts[0]->posts); } } else { $total_posts = (int) $groups_template->group->forum_counts[0]->posts; } return apply_filters('bp_get_group_forum_post_count', $total_posts, (bool) $showtext); }
/** * Generate the post count string for a group forum. * * @since 1.2.0 * * @param array|string $args { * Array of arguments. * @type bool $showtext Optional. If true, result will be formatted as "x posts". * If false, just a number will be returned. * Default: false. * } * @return string|int */ function bp_get_group_forum_post_count($args = '') { global $groups_template; $defaults = array('showtext' => false); $r = wp_parse_args($args, $defaults); extract($r, EXTR_SKIP); if (!($forum_id = groups_get_groupmeta($groups_template->group->id, 'forum_id'))) { return false; } if (!bp_is_active('forums')) { return false; } if (!$groups_template->group->forum_counts) { $groups_template->group->forum_counts = bp_forums_get_forum_topicpost_count((int) $forum_id); } if ((bool) $showtext) { if (1 == (int) $groups_template->group->forum_counts[0]->posts) { $total_posts = sprintf(__('%d post', 'buddypress'), (int) $groups_template->group->forum_counts[0]->posts); } else { $total_posts = sprintf(__('%d posts', 'buddypress'), (int) $groups_template->group->forum_counts[0]->posts); } } else { $total_posts = (int) $groups_template->group->forum_counts[0]->posts; } /** * Filters the post count string for a group forum. * * @since 1.2.0 * * @param string $total_posts Total post count string. * @param bool $showtext Whether or not to return as formatted string. */ return apply_filters('bp_get_group_forum_post_count', $total_posts, (bool) $showtext); }