BP_Friends_Component::setup_admin_bar( array $wp_admin_nav = array() )
Set up bp-friends integration with the WordPress admin bar.
Description
See also
- BP_Component::setup_admin_bar(): for a description of arguments.
Parameters
- $wp_admin_nav
-
(Optional) See BP_Component::setup_admin_bar() for description.
Default value: array()
Source
File: bp-friends/classes/class-bp-friends-component.php
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | 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 */ __( 'Connections %s' , 'buddyboss' ), '<span class="count">' . bp_core_number_format( $count ) . '</span>' ); $pending = sprintf( /* translators: %s: Pending friend request count for the current user */ __( 'Pending Requests %s' , 'buddyboss' ), '<span class="count">' . bp_core_number_format( $count ) . '</span>' ); } else { $title = __( 'Connections' , 'buddyboss' ); $pending = __( 'No Pending Requests' , 'buddyboss' ); } // 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 Connections. $wp_admin_nav [] = array ( 'parent' => 'my-account-' . $this ->id, 'id' => 'my-account-' . $this ->id . '-friendships' , 'title' => __( 'My Connections' , 'buddyboss' ), '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
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.