BP_REST_Members_Details_Endpoint::bp_rest_get_nav_count( array $nav )

Retrieve the count attribute for the current nav item.

Description

Parameters

$nav

(Required) Navigation array.

Return

(int) The count attribute for the nav item.

Source

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

646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
protected function bp_rest_get_nav_count( $nav ) {
    $count = 0;
 
    if ( ! empty( $nav['primary'] ) ) {
        $span = strpos( $nav['name'], '<span' );
 
        // Grab count out of the <span> element.
        if ( false !== $span ) {
            $count_start = strpos( $nav['name'], '>', $span ) + 1;
            $count_end   = strpos( $nav['name'], '<', $count_start );
            $count       = (int) substr( $nav['name'], $count_start, $count_end - $count_start );
        }
    }
 
    /**
     * Filter to edit the count attribute for the nav item.
     *
     * @param int   $count    The count attribute for the nav item.
     * @param array $nav_item The current nav item array.
     */
    return (int) apply_filters( 'bp_rest_nouveau_get_nav_count', $count, $nav );
}

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.