wpseek.com
A WordPress-centric search engine for devs and theme authors
wp_admin_bar_my_account_item › WordPress Function
Since3.3.0
Deprecatedn/a
› wp_admin_bar_my_account_item ( $wp_admin_bar )
| Parameters: |
|
| Defined at: |
|
| Codex: |
Adds the "My Account" item.
Source
function wp_admin_bar_my_account_item( $wp_admin_bar ) {
$user_id = get_current_user_id();
if ( ! $user_id ) {
return;
}
if ( current_user_can( 'read' ) ) {
$profile_url = get_edit_profile_url( $user_id );
} elseif ( is_multisite() ) {
$profile_url = get_dashboard_url( $user_id, 'profile.php' );
} else {
$profile_url = false;
}
/* translators: %s: Current user's display name. */
$howdy = sprintf( __( 'Howdy, %s' ), '<span class="display-name">' . wp_get_current_user()->display_name . '</span>' );
$avatar = get_avatar( $user_id, 26 );
$wp_admin_bar->add_node(
array(
'id' => 'my-account',
'parent' => 'top-secondary',
'title' => $howdy . $avatar,
'href' => $profile_url,
'meta' => array(
'class' => empty( $avatar ) ? '' : 'with-avatar',
'menu_title' => wp_strip_all_tags( $howdy ),
'tabindex' => ( false !== $profile_url ) ? '' : 0,
),
)
);
}