BP_REST_Groups_Details_Endpoint::bp_rest_get_nav_count( BP_Groups_Group $group, array $nav )

Retrieve the count attribute for the current nav item.

Description

Parameters

$group

(BP_Groups_Group) (Optional) Group object. Default: current group in loop.

$nav

(array) (Optional) Navigation array.

Return

(int) The count attribute for the nav item.

Source

File: bp-groups/classes/class-bp-rest-groups-details-endpoint.php

	protected function bp_rest_get_nav_count( $group, $nav ) {
		$nav_item = $nav['slug'];

		if ( 'members' === $nav_item || 'all-members' === $nav_item ) {
			$count = $group->total_member_count;
		} elseif ( 'subgroups' === $nav_item ) {
			$count = count( bp_get_descendent_groups( $group->id, bp_loggedin_user_id() ) );
		} elseif ( bp_is_active( 'media' ) && bp_is_group_media_support_enabled() && 'photos' === $nav_item && function_exists( 'bp_is_group_media_support_enabled' ) ) {
			$count = bp_media_get_total_group_media_count( $group->id );
		} elseif ( bp_is_active( 'media' ) && bp_is_group_albums_support_enabled() && 'albums' === $nav_item && function_exists( 'bp_is_group_albums_support_enabled' ) ) {
			$count = bp_media_get_total_group_album_count( $group->id );
		} elseif ( 'leaders' === $nav_item ) {
			$admins = groups_get_group_admins( $group->id );
			$mods   = groups_get_group_mods( $group->id );
			$count  = count( $admins ) + count( $mods );
		}

		if ( ! isset( $count ) ) {
			return false;
		}

		return $count;
	}

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.