Introduce user-actions group and move profile and logout menu items to it and change priority. Props koopersmith. fixes #19425

git-svn-id: http://svn.automattic.com/wordpress/trunk@19559 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2011-12-06 03:51:58 +00:00
parent 06a1675a3c
commit d295e6e600
6 changed files with 79 additions and 53 deletions

View File

@ -125,7 +125,36 @@ function wp_admin_bar_wp_menu( $wp_admin_bar ) {
}
/**
* Add the "My Account" menu and all submenus.
* Add the "My Account" item.
*
* @since 3.3.0
*/
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'),
),
) );
}
/**
* Add the "My Account" submenu items.
*
* @since 3.1.0
*/
@ -134,53 +163,41 @@ function wp_admin_bar_my_account_menu( $wp_admin_bar ) {
$current_user = wp_get_current_user();
$profile_url = get_edit_profile_url( $user_id );
if ( 0 != $user_id ) {
/* Add the "My Account" menu */
$avatar = get_avatar( $user_id, 16 );
$howdy = sprintf( __('Howdy, %1$s'), $current_user->display_name );
$class = empty( $avatar ) ? '' : 'with-avatar';
if ( ! $user_id )
return;
$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'),
),
) );
$wp_admin_bar->add_group( array(
'parent' => 'my-account',
'id' => 'user-actions',
) );
/* Add the "My Account" sub menus */
$user_info = get_avatar( $user_id, 64 );
$user_info .= "<span class='display-name'>{$current_user->display_name}</span>";
$user_info = get_avatar( $user_id, 64 );
$user_info .= "<span class='display-name'>{$current_user->display_name}</span>";
if ( $current_user->display_name !== $current_user->user_nicename )
$user_info .= "<span class='username'>{$current_user->user_nicename}</span>";
if ( $current_user->display_name !== $current_user->user_nicename )
$user_info .= "<span class='username'>{$current_user->user_nicename}</span>";
$wp_admin_bar->add_menu( array(
'parent' => 'my-account',
'id' => 'user-info',
'title' => $user_info,
'href' => $profile_url,
'meta' => array(
'tabindex' => -1
),
) );
$wp_admin_bar->add_menu( array(
'parent' => 'my-account',
'id' => 'edit-profile',
'title' => __( 'Edit My Profile' ),
'href' => $profile_url,
) );
$wp_admin_bar->add_menu( array(
'parent' => 'my-account',
'id' => 'logout',
'title' => __( 'Log Out' ),
'href' => wp_logout_url(),
) );
}
$wp_admin_bar->add_menu( array(
'parent' => 'user-actions',
'id' => 'user-info',
'title' => $user_info,
'href' => $profile_url,
'meta' => array(
'tabindex' => -1,
),
) );
$wp_admin_bar->add_menu( array(
'parent' => 'user-actions',
'id' => 'edit-profile',
'title' => __( 'Edit My Profile' ),
'href' => $profile_url,
) );
$wp_admin_bar->add_menu( array(
'parent' => 'user-actions',
'id' => 'logout',
'title' => __( 'Log Out' ),
'href' => wp_logout_url(),
) );
}
/**

View File

@ -448,8 +448,9 @@ class WP_Admin_Bar {
public function add_menus() {
// User related, aligned right.
add_action( 'admin_bar_menu', 'wp_admin_bar_search_menu', 10 );
add_action( 'admin_bar_menu', 'wp_admin_bar_my_account_menu', 20 );
add_action( 'admin_bar_menu', 'wp_admin_bar_my_account_menu', 0 );
add_action( 'admin_bar_menu', 'wp_admin_bar_search_menu', 4 );
add_action( 'admin_bar_menu', 'wp_admin_bar_my_account_item', 7 );
// Site related.
add_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu', 10 );

View File

@ -1 +1 @@
#wpadminbar *{font-family:Tahoma,Arial,Helvetica,sans-serif;}#wpadminbar{direction:rtl;font-family:Tahoma,Arial,Helvetica,sans-serif;left:auto;right:0;}#wpadminbar .quicklinks{border-left:0;border-right:1px solid transparent;}#wpadminbar .quicklinks ul{text-align:right;}#wpadminbar li{float:right;}#wpadminbar .quicklinks>ul>li{border-right:0;border-left:1px solid #555;}#wpadminbar .quicklinks>ul>li>a,#wpadminbar .quicklinks>ul>li>.ab-empty-item{border-right:0;border-left:1px solid #333;}#wpadminbar .quicklinks .ab-top-secondary>li{border-left:0;border-right:1px solid #333;float:left;}#wpadminbar .quicklinks .ab-top-secondary>li>a,#wpadminbar .quicklinks .ab-top-secondary>li>.ab-empty-item{border-right:1px solid #555;border-left:0;}#wpadminbar .menupop .ab-sub-wrapper,#wpadminbar .shortlink-input{margin:0 -1px 0 0;}#wpadminbar.ie7 .menupop .ab-sub-wrapper,#wpadminbar.ie7 .shortlink-input{left:auto;right:0;}#wpadminbar .ab-top-secondary .menupop .ab-sub-wrapper{right:auto;left:0;margin:0 0 0 -1px;}#wpadminbar .menupop li:hover>.ab-sub-wrapper,#wpadminbar .menupop li.hover>.ab-sub-wrapper{margin-left:0;margin-right:100%;}#wpadminbar .ab-top-secondary .menupop li:hover>.ab-sub-wrapper,#wpadminbar .ab-top-secondary .menupop li.hover>.ab-sub-wrapper{margin-left:inherit;margin-right:0;left:100%;right:inherit;}#wpadminbar .menupop .menupop>.ab-item{background-position:5% -46px;padding-left:2em;padding-right:1em;}#wpadminbar .ab-top-secondary .menupop .menupop>.ab-item{background-position:95% -20px;padding-left:1em;padding-right:2em;}#wpadminbar .quicklinks .menupop ul.ab-sub-secondary{right:0;left:auto;}#wpadminbar .ab-top-secondary{float:left;right:auto;left:0;}#wpadminbar ul li:last-child,#wpadminbar ul li:last-child .ab-item{border-left:0;}#wpadminbar #wp-admin-bar-my-account.with-avatar #wp-admin-bar-my-account-default>li{margin-right:88px;margin-left:16px;}#wp-admin-bar-my-account-default>li>.ab-item{padding-left:0;padding-right:8px;}#wp-admin-bar-user-info .avatar{left:auto;right:-72px;}#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar>a img{margin-left:-1px;margin-right:4px;}#wpadminbar .quicklinks li img.blavatar{margin-right:0;margin-left:4px;}#wpadminbar #adminbarsearch .adminbar-input{font-family:Tahoma,Arial,Helvetica,sans-serif;padding:0 24px 0 3px;margin:0;background-position:50% 2px;}#wpadminbar #adminbarsearch .adminbar-input:focus,#wpadminbar.ie7 #adminbarsearch .adminbar-input{background-position:99% 2px;}#wpadminbar .ab-icon{float:right;}#wpadminbar.ie7 .ab-icon{float:left;left:12px;}#wpadminbar .ab-label{margin-left:0;margin-right:4px;}#wpadminbar.ie7 #wp-admin-bar-comments>a{min-width:25px;}#wpadminbar a:hover .ab-comments-icon-arrow{border-right-color:#bbb;}#wpadminbar .menupop .ab-sub-wrapper,#wpadminbar .shortlink-input{right:0;}#wpadminbar .quicklinks .menupop ul li a{position:relative;}* html #wpadminbar .quicklinks ul li a{float:right;}
#wpadminbar *{font-family:Tahoma,Arial,Helvetica,sans-serif;}#wpadminbar{direction:rtl;font-family:Tahoma,Arial,Helvetica,sans-serif;left:auto;right:0;}#wpadminbar .quicklinks{border-left:0;border-right:1px solid transparent;}#wpadminbar .quicklinks ul{text-align:right;}#wpadminbar li{float:right;}#wpadminbar .quicklinks>ul>li{border-right:0;border-left:1px solid #555;}#wpadminbar .quicklinks>ul>li>a,#wpadminbar .quicklinks>ul>li>.ab-empty-item{border-right:0;border-left:1px solid #333;}#wpadminbar .quicklinks .ab-top-secondary>li{border-left:0;border-right:1px solid #333;float:left;}#wpadminbar .quicklinks .ab-top-secondary>li>a,#wpadminbar .quicklinks .ab-top-secondary>li>.ab-empty-item{border-right:1px solid #555;border-left:0;}#wpadminbar .menupop .ab-sub-wrapper,#wpadminbar .shortlink-input{margin:0 -1px 0 0;}#wpadminbar.ie7 .menupop .ab-sub-wrapper,#wpadminbar.ie7 .shortlink-input{left:auto;right:0;}#wpadminbar .ab-top-secondary .menupop .ab-sub-wrapper{right:auto;left:0;margin:0 0 0 -1px;}#wpadminbar .menupop li:hover>.ab-sub-wrapper,#wpadminbar .menupop li.hover>.ab-sub-wrapper{margin-left:0;margin-right:100%;}#wpadminbar .ab-top-secondary .menupop li:hover>.ab-sub-wrapper,#wpadminbar .ab-top-secondary .menupop li.hover>.ab-sub-wrapper{margin-left:inherit;margin-right:0;left:100%;right:inherit;}#wpadminbar .menupop .menupop>.ab-item{background-position:5% -46px;padding-left:2em;padding-right:1em;}#wpadminbar .ab-top-secondary .menupop .menupop>.ab-item{background-position:95% -20px;padding-left:1em;padding-right:2em;}#wpadminbar .quicklinks .menupop ul.ab-sub-secondary{right:0;left:auto;}#wpadminbar .ab-top-secondary{float:left;right:auto;left:0;}#wpadminbar ul li:last-child,#wpadminbar ul li:last-child .ab-item{border-left:0;}#wpadminbar #wp-admin-bar-my-account.with-avatar #wp-admin-bar-user-actions>li{margin-right:88px;margin-left:16px;}#wp-admin-bar-user-actions>li>.ab-item{padding-left:0;padding-right:8px;}#wp-admin-bar-user-info .avatar{left:auto;right:-72px;}#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar>a img{margin-left:-1px;margin-right:4px;}#wpadminbar .quicklinks li img.blavatar{margin-right:0;margin-left:4px;}#wpadminbar #adminbarsearch .adminbar-input{font-family:Tahoma,Arial,Helvetica,sans-serif;padding:0 24px 0 3px;margin:0;background-position:50% 2px;}#wpadminbar #adminbarsearch .adminbar-input:focus,#wpadminbar.ie7 #adminbarsearch .adminbar-input{background-position:99% 2px;}#wpadminbar .ab-icon{float:right;}#wpadminbar.ie7 .ab-icon{float:left;left:12px;}#wpadminbar .ab-label{margin-left:0;margin-right:4px;}#wpadminbar.ie7 #wp-admin-bar-comments>a{min-width:25px;}#wpadminbar a:hover .ab-comments-icon-arrow{border-right-color:#bbb;}#wpadminbar .menupop .ab-sub-wrapper,#wpadminbar .shortlink-input{right:0;}#wpadminbar .quicklinks .menupop ul li a{position:relative;}* html #wpadminbar .quicklinks ul li a{float:right;}

View File

@ -107,12 +107,12 @@
/**
* My Account
*/
#wpadminbar #wp-admin-bar-my-account.with-avatar #wp-admin-bar-my-account-default > li {
#wpadminbar #wp-admin-bar-my-account.with-avatar #wp-admin-bar-user-actions > li {
margin-right: 88px;
margin-left: 16px;
}
#wp-admin-bar-my-account-default > li > .ab-item {
#wp-admin-bar-user-actions > li > .ab-item {
padding-left: 0;
padding-right: 8px;
}

File diff suppressed because one or more lines are too long

View File

@ -323,16 +323,16 @@
min-width: 270px;
}
#wpadminbar #wp-admin-bar-my-account-default > li {
#wpadminbar #wp-admin-bar-user-actions > li {
margin-left: 16px;
margin-right: 16px;
}
#wpadminbar #wp-admin-bar-my-account.with-avatar #wp-admin-bar-my-account-default > li {
#wpadminbar #wp-admin-bar-my-account.with-avatar #wp-admin-bar-user-actions > li {
margin-left: 88px;
}
#wp-admin-bar-my-account-default > li > .ab-item {
#wp-admin-bar-user-actions > li > .ab-item {
padding-left: 8px;
}
@ -488,6 +488,14 @@
margin-top: -12px;
}
/**
* Site Menu
*/
#wpadminbar #wp-admin-bar-appearance {
border-top: none;
margin-top: -12px;
}
/**
* ICONS
*/