BP_Messages_Component::setup_admin_bar( array $wp_admin_nav = array() )
Set up the Toolbar.
Description
Parameters
- $wp_admin_nav
-
(Optional) See {BP_Component::setup_admin_bar()} for details.
Default value: array()
Source
File: bp-messages/classes/class-bp-messages-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.
$messages_link = trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() );
// Unread message count.
$count = messages_get_unread_count( bp_loggedin_user_id() );
if ( !empty( $count ) ) {
$title = sprintf(
/* translators: %s: Unread message count for the current user */
__( 'Messages %s', 'buddyboss' ),
'<span class="count">' . bp_core_number_format( $count ) . '</span>'
);
$inbox = sprintf(
/* translators: %s: Unread message count for the current user */
__( 'Messages %s', 'buddyboss' ),
'<span class="count">' . bp_core_number_format( $count ) . '</span>'
);
} else {
$title = __( 'Messages', 'buddyboss' );
$inbox = __( 'Messages', 'buddyboss' );
}
// Add main Messages menu.
$wp_admin_nav[] = array(
'parent' => buddypress()->my_account_menu_id,
'id' => 'my-account-' . $this->id,
'title' => $title,
'href' => $messages_link
);
// Inbox.
$wp_admin_nav[] = array(
'parent' => 'my-account-' . $this->id,
'id' => 'my-account-' . $this->id . '-inbox',
'title' => $inbox,
'href' => $messages_link,
'position' => 10
);
// Compose Message.
$wp_admin_nav[] = array(
'parent' => 'my-account-' . $this->id,
'id' => 'my-account-' . $this->id . '-compose',
'title' => __( 'New Message', 'buddyboss' ),
'href' => trailingslashit( $messages_link . 'compose' ),
'position' => 30
);
// Site Wide Notices.
if ( bp_current_user_can( 'bp_moderate' ) ) {
$wp_admin_nav[] = array(
'parent' => 'my-account-' . $this->id,
'id' => 'my-account-' . $this->id . '-notices',
'title' => __( 'Site Notices', 'buddyboss' ),
'href' => trailingslashit( $messages_link . 'notices' ),
'position' => 90
);
}
}
parent::setup_admin_bar( $wp_admin_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.