BP_Friends_Component::setup_admin_bar( array $wp_admin_nav = array() )
Set up bp-friends integration with the WordPress admin bar.
Description Description
See also See also
- BP_Component::setup_admin_bar(): for a description of arguments.
Parameters Parameters
- $wp_admin_nav
-
(Optional) See BP_Component::setup_admin_bar() for description.
Default value: array()
Source Source
File: bp-friends/classes/class-bp-friends-component.php
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. $friends_link = trailingslashit( bp_loggedin_user_domain() . bp_get_friends_slug() ); // Pending friend requests. $count = count( friends_get_friendship_request_user_ids( bp_loggedin_user_id() ) ); if ( !empty( $count ) ) { $title = sprintf( /* translators: %s: Pending friend request count for the current user */ _x( 'Friends %s', 'My Account Friends menu', 'buddypress' ), '<span class="count">' . bp_core_number_format( $count ) . '</span>' ); $pending = sprintf( /* translators: %s: Pending friend request count for the current user */ _x( 'Pending Requests %s', 'My Account Friends menu sub nav', 'buddypress' ), '<span class="count">' . bp_core_number_format( $count ) . '</span>' ); } else { $title = _x( 'Friends', 'My Account Friends menu', 'buddypress' ); $pending = _x( 'No Pending Requests','My Account Friends menu sub nav', 'buddypress' ); } // Add the "My Account" sub menus. $wp_admin_nav[] = array( 'parent' => buddypress()->my_account_menu_id, 'id' => 'my-account-' . $this->id, 'title' => $title, 'href' => $friends_link ); // My Friends. $wp_admin_nav[] = array( 'parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-friendships', 'title' => _x( 'Friendships', 'My Account Friends menu sub nav', 'buddypress' ), 'href' => $friends_link, 'position' => 10 ); // Requests. $wp_admin_nav[] = array( 'parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-requests', 'title' => $pending, 'href' => trailingslashit( $friends_link . 'requests' ), 'position' => 20 ); } parent::setup_admin_bar( $wp_admin_nav ); }
Changelog Changelog
Version | Description |
---|---|
1.5.0 | Introduced. |