BP_Activity_Component::setup_admin_bar( array $wp_admin_nav = array() )
Set up the component entries in the WordPress Admin Bar.
Description
See also
- BP_Component::setup_nav(): for a description of the $wp_admin_nav parameter array.
Parameters
- $wp_admin_nav
-
(Optional) See BP_Component::setup_admin_bar() for a description.
Default value: array()
Source
File: bp-activity/classes/class-bp-activity-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.
$activity_link = trailingslashit( bp_loggedin_user_domain() . bp_get_activity_slug() );
// Unread message count.
if ( bp_activity_do_mentions() ) {
$count = bp_get_total_mention_count_for_user( bp_loggedin_user_id() );
if ( !empty( $count ) ) {
$title = sprintf(
/* translators: %s: Unread mention count for the current user */
__( 'Mentions %s', 'buddyboss' ),
'<span class="count">' . bp_core_number_format( $count ) . '</span>'
);
} else {
$title = __( 'Mentions', 'buddyboss' );
}
}
// Add the "Activity" sub menu.
$wp_admin_nav[] = array(
'parent' => buddypress()->my_account_menu_id,
'id' => 'my-account-' . $this->id,
'title' => __( 'Timeline', 'buddyboss' ),
'href' => $activity_link
);
// Personal.
$wp_admin_nav[] = array(
'parent' => 'my-account-' . $this->id,
'id' => 'my-account-' . $this->id . '-personal',
'title' => __( 'Posts', 'buddyboss' ),
'href' => $activity_link,
'position' => 10
);
}
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.