wp_admin_bar_my_account_item

The timeline below displays how wordpress function wp_admin_bar_my_account_item has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.5

/**
 * Adds the "My Account" item.
 *
 * @since 3.3.0
 *
 * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
 */
function wp_admin_bar_my_account_item($wp_admin_bar)
{
    $user_id = get_current_user_id();
    $current_user = wp_get_current_user();
    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;
    }
    $avatar = get_avatar($user_id, 26);
    /* translators: %s: Current user's display name. */
    $howdy = sprintf(__('Howdy, %s'), '<span class="display-name">' . $current_user->display_name . '</span>');
    $class = empty($avatar) ? '' : 'with-avatar';
    $wp_admin_bar->add_node(array('id' => 'my-account', 'parent' => 'top-secondary', 'title' => $howdy . $avatar, 'href' => $profile_url, 'meta' => array(
        'class' => $class,
        /* translators: %s: Current user's display name. */
        'menu_title' => sprintf(__('Howdy, %s'), $current_user->display_name),
        'tabindex' => (false !== $profile_url) ? '' : 0,
    )));
}

WordPress Version: 5.9

/**
 * Adds the "My Account" item.
 *
 * @since 3.3.0
 *
 * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
 */
function wp_admin_bar_my_account_item($wp_admin_bar)
{
    $user_id = get_current_user_id();
    $current_user = wp_get_current_user();
    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;
    }
    $avatar = get_avatar($user_id, 26);
    /* translators: %s: Current user's display name. */
    $howdy = sprintf(__('Howdy, %s'), '<span class="display-name">' . $current_user->display_name . '</span>');
    $class = empty($avatar) ? '' : 'with-avatar';
    $wp_admin_bar->add_node(array('id' => 'my-account', 'parent' => 'top-secondary', 'title' => $howdy . $avatar, 'href' => $profile_url, 'meta' => array('class' => $class)));
}

WordPress Version: 5.4

/**
 * Add the "My Account" item.
 *
 * @since 3.3.0
 *
 * @param WP_Admin_Bar $wp_admin_bar
 */
function wp_admin_bar_my_account_item($wp_admin_bar)
{
    $user_id = get_current_user_id();
    $current_user = wp_get_current_user();
    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;
    }
    $avatar = get_avatar($user_id, 26);
    /* translators: %s: Current user's display name. */
    $howdy = sprintf(__('Howdy, %s'), '<span class="display-name">' . $current_user->display_name . '</span>');
    $class = empty($avatar) ? '' : 'with-avatar';
    $wp_admin_bar->add_node(array('id' => 'my-account', 'parent' => 'top-secondary', 'title' => $howdy . $avatar, 'href' => $profile_url, 'meta' => array('class' => $class)));
}

WordPress Version: 5.3

/**
 * Add the "My Account" item.
 *
 * @since 3.3.0
 *
 * @param WP_Admin_Bar $wp_admin_bar
 */
function wp_admin_bar_my_account_item($wp_admin_bar)
{
    $user_id = get_current_user_id();
    $current_user = wp_get_current_user();
    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;
    }
    $avatar = get_avatar($user_id, 26);
    /* translators: %s: Current user's display name. */
    $howdy = sprintf(__('Howdy, %s'), '<span class="display-name">' . $current_user->display_name . '</span>');
    $class = empty($avatar) ? '' : 'with-avatar';
    $wp_admin_bar->add_menu(array('id' => 'my-account', 'parent' => 'top-secondary', 'title' => $howdy . $avatar, 'href' => $profile_url, 'meta' => array('class' => $class)));
}

WordPress Version: 4.8

/**
 * Add the "My Account" item.
 *
 * @since 3.3.0
 *
 * @param WP_Admin_Bar $wp_admin_bar
 */
function wp_admin_bar_my_account_item($wp_admin_bar)
{
    $user_id = get_current_user_id();
    $current_user = wp_get_current_user();
    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;
    }
    $avatar = get_avatar($user_id, 26);
    /* translators: %s: current user's display name */
    $howdy = sprintf(__('Howdy, %s'), '<span class="display-name">' . $current_user->display_name . '</span>');
    $class = empty($avatar) ? '' : 'with-avatar';
    $wp_admin_bar->add_menu(array('id' => 'my-account', 'parent' => 'top-secondary', 'title' => $howdy . $avatar, 'href' => $profile_url, 'meta' => array('class' => $class)));
}

WordPress Version: 4.7

/**
 * Add the "My Account" item.
 *
 * @since 3.3.0
 *
 * @param WP_Admin_Bar $wp_admin_bar
 */
function wp_admin_bar_my_account_item($wp_admin_bar)
{
    $user_id = get_current_user_id();
    $current_user = wp_get_current_user();
    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;
    }
    $avatar = get_avatar($user_id, 26);
    /* translators: %s: current user's display name */
    $howdy = sprintf(__('Howdy, %s'), $current_user->display_name);
    $class = empty($avatar) ? '' : 'with-avatar';
    $wp_admin_bar->add_menu(array('id' => 'my-account', 'parent' => 'top-secondary', 'title' => $howdy . $avatar, 'href' => $profile_url, 'meta' => array('class' => $class)));
}

WordPress Version: 4.4

/**
 * Add the "My Account" item.
 *
 * @since 3.3.0
 *
 * @param WP_Admin_Bar $wp_admin_bar
 */
function wp_admin_bar_my_account_item($wp_admin_bar)
{
    $user_id = get_current_user_id();
    $current_user = wp_get_current_user();
    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;
    }
    $avatar = get_avatar($user_id, 26);
    $howdy = sprintf(__('Howdy, %1$s'), $current_user->display_name);
    $class = empty($avatar) ? '' : 'with-avatar';
    $wp_admin_bar->add_menu(array('id' => 'my-account', 'parent' => 'top-secondary', 'title' => $howdy . $avatar, 'href' => $profile_url, 'meta' => array('class' => $class)));
}

WordPress Version: 4.2

/**
 * Add the "My Account" item.
 *
 * @since 3.3.0
 *
 * @param WP_Admin_Bar $wp_admin_bar
 */
function wp_admin_bar_my_account_item($wp_admin_bar)
{
    $user_id = get_current_user_id();
    $current_user = wp_get_current_user();
    $profile_url = get_edit_profile_url($user_id);
    if (!$user_id) {
        return;
    }
    $avatar = get_avatar($user_id, 26);
    $howdy = sprintf(__('Howdy, %1$s'), $current_user->display_name);
    $class = empty($avatar) ? '' : 'with-avatar';
    $wp_admin_bar->add_menu(array('id' => 'my-account', 'parent' => 'top-secondary', 'title' => $howdy . $avatar, 'href' => $profile_url, 'meta' => array('class' => $class)));
}

WordPress Version: 3.8

/**
 * Add the "My Account" item.
 *
 * @since 3.3.0
 *
 * @param WP_Admin_Bar $wp_admin_bar
 */
function wp_admin_bar_my_account_item($wp_admin_bar)
{
    $user_id = get_current_user_id();
    $current_user = wp_get_current_user();
    $profile_url = get_edit_profile_url($user_id);
    if (!$user_id) {
        return;
    }
    $avatar = get_avatar($user_id, 26);
    $howdy = sprintf(__('Howdy, %1$s'), $current_user->display_name);
    $class = empty($avatar) ? '' : 'with-avatar';
    $wp_admin_bar->add_menu(array('id' => 'my-account', 'parent' => 'top-secondary', 'title' => $howdy . $avatar, 'href' => $profile_url, 'meta' => array('class' => $class, 'title' => __('My Account'))));
}

WordPress Version: 3.7

/**
 * Add the "My Account" item.
 *
 * @since 3.3.0
 *
 * @param WP_Admin_Bar $wp_admin_bar
 */
function wp_admin_bar_my_account_item($wp_admin_bar)
{
    $user_id = get_current_user_id();
    $current_user = wp_get_current_user();
    $profile_url = get_edit_profile_url($user_id);
    if (!$user_id) {
        return;
    }
    $avatar = get_avatar($user_id, 16);
    $howdy = sprintf(__('Howdy, %1$s'), $current_user->display_name);
    $class = empty($avatar) ? '' : 'with-avatar';
    $wp_admin_bar->add_menu(array('id' => 'my-account', 'parent' => 'top-secondary', 'title' => $howdy . $avatar, 'href' => $profile_url, 'meta' => array('class' => $class, 'title' => __('My Account'))));
}