BP_Groups_Component::setup_admin_bar( array $wp_admin_nav = array() )

Set up the component entries in the WordPress Admin Bar.

Description

See also

Parameters

$wp_admin_nav

(Optional) See BP_Component::setup_admin_bar() for a description.

Default value: array()

Source

File: bp-groups/classes/class-bp-groups-component.php

973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
public function setup_admin_bar( $wp_admin_nav = array() ) {
 
    // Menus for logged in user.
    if ( is_user_logged_in() ) {
 
        // Setup the logged in user variables.
        $groups_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() );
 
        // Pending group invites.
        $count   = groups_get_invite_count_for_user();
        $title   = __( 'Groups', 'buddyboss' );
        $pending = __( 'No Pending Invites', 'buddyboss' );
 
        if ( ! empty( $count ) ) {
            $title = sprintf(
                /* translators: %s: Group invitation count for the current user */
                __( 'Groups %s', 'buddyboss' ),
                '<span class="count">' . bp_core_number_format( $count ) . '</span>'
            );
 
            $pending = sprintf(
                /* translators: %s: Group invitation count for the current user */
                __( 'Pending Invites %s', 'buddyboss' ),
                '<span class="count">' . bp_core_number_format( $count ) . '</span>'
            );
        }
 
        // Add the "My Account" sub menus.
        $wp_admin_nav[] = array(
            'parent' => buddypress()->my_account_menu_id,
            'id'     => 'my-account-' . $this->id,
            'title'  => $title,
            'href'   => $groups_link
        );
 
        // My Groups.
        $wp_admin_nav[] = array(
            'parent'   => 'my-account-' . $this->id,
            'id'       => 'my-account-' . $this->id . '-memberships',
            'title'    => __( 'My Groups', 'buddyboss' ),
            'href'     => $groups_link,
            'position' => 10
        );
 
        // Invitations.
        $wp_admin_nav[] = array(
            'parent'   => 'my-account-' . $this->id,
            'id'       => 'my-account-' . $this->id . '-invites',
            'title'    => $pending,
            'href'     => trailingslashit( $groups_link . 'invites' ),
            'position' => 30
        );
 
        // Create a Group.
        if ( bp_user_can_create_groups() ) {
            $wp_admin_nav[] = array(
                'parent'   => 'my-account-' . $this->id,
                'id'       => 'my-account-' . $this->id . '-create',
                'title'    => __( 'Create Group', 'buddyboss' ),
                'href'     => trailingslashit( bp_get_groups_directory_permalink() . 'create' ),
                'position' => 90
            );
        }
    }
 
    parent::setup_admin_bar( $wp_admin_nav );
}

Changelog

Changelog
Version Description
BuddyPress 1.5.0 Introduced.

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.