mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-16 19:46:21 +00:00
Update links to the user profile editing screen in the admin toolbar when the current logged in user has no role on the current site. Covers single site and Multisite and introduces tests.
Fixes #25162 Built from https://develop.svn.wordpress.org/trunk@34122 git-svn-id: http://core.svn.wordpress.org/trunk@34090 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
edd0f2b32f
commit
bc6af23302
@ -179,11 +179,18 @@ function wp_admin_bar_sidebar_toggle( $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;
|
||||
|
||||
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';
|
||||
@ -209,11 +216,18 @@ function wp_admin_bar_my_account_item( $wp_admin_bar ) {
|
||||
function wp_admin_bar_my_account_menu( $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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
$wp_admin_bar->add_group( array(
|
||||
'parent' => 'my-account',
|
||||
'id' => 'user-actions',
|
||||
@ -234,12 +248,16 @@ function wp_admin_bar_my_account_menu( $wp_admin_bar ) {
|
||||
'tabindex' => -1,
|
||||
),
|
||||
) );
|
||||
$wp_admin_bar->add_menu( array(
|
||||
'parent' => 'user-actions',
|
||||
'id' => 'edit-profile',
|
||||
'title' => __( 'Edit My Profile' ),
|
||||
'href' => $profile_url,
|
||||
) );
|
||||
|
||||
if ( false !== $profile_url ) {
|
||||
$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',
|
||||
@ -281,7 +299,7 @@ function wp_admin_bar_site_menu( $wp_admin_bar ) {
|
||||
$wp_admin_bar->add_menu( array(
|
||||
'id' => 'site-name',
|
||||
'title' => $title,
|
||||
'href' => is_admin() ? home_url( '/' ) : admin_url(),
|
||||
'href' => ( is_admin() || ! current_user_can( 'read' ) ) ? home_url( '/' ) : admin_url(),
|
||||
) );
|
||||
|
||||
// Create submenu items.
|
||||
@ -304,7 +322,7 @@ function wp_admin_bar_site_menu( $wp_admin_bar ) {
|
||||
) );
|
||||
}
|
||||
|
||||
} else {
|
||||
} else if ( current_user_can( 'read' ) ) {
|
||||
// We're on the front end, link to the Dashboard.
|
||||
$wp_admin_bar->add_menu( array(
|
||||
'parent' => 'site-name',
|
||||
|
@ -27,6 +27,11 @@ html:lang(he-il) .rtl #wpadminbar * {
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
|
||||
#wpadminbar .ab-empty-item {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
#wpadminbar .ab-empty-item,
|
||||
#wpadminbar a.ab-item,
|
||||
#wpadminbar > #wp-toolbar span.ab-label,
|
||||
#wpadminbar > #wp-toolbar span.noticon {
|
||||
@ -451,6 +456,7 @@ html:lang(he-il) .rtl #wpadminbar * {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
#wpadminbar #wp-admin-bar-my-account.with-avatar > .ab-empty-item img,
|
||||
#wpadminbar #wp-admin-bar-my-account.with-avatar > a img {
|
||||
width: auto;
|
||||
height: 16px;
|
||||
@ -464,6 +470,7 @@ html:lang(he-il) .rtl #wpadminbar * {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#wpadminbar.ie8 #wp-admin-bar-my-account.with-avatar > .ab-empty-item img,
|
||||
#wpadminbar.ie8 #wp-admin-bar-my-account.with-avatar > a img {
|
||||
width: auto;
|
||||
}
|
||||
|
2
wp-includes/css/admin-bar-rtl.min.css
vendored
2
wp-includes/css/admin-bar-rtl.min.css
vendored
File diff suppressed because one or more lines are too long
@ -27,6 +27,11 @@ html:lang(he-il) .rtl #wpadminbar * {
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
|
||||
#wpadminbar .ab-empty-item {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
#wpadminbar .ab-empty-item,
|
||||
#wpadminbar a.ab-item,
|
||||
#wpadminbar > #wp-toolbar span.ab-label,
|
||||
#wpadminbar > #wp-toolbar span.noticon {
|
||||
@ -451,6 +456,7 @@ html:lang(he-il) .rtl #wpadminbar * {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
#wpadminbar #wp-admin-bar-my-account.with-avatar > .ab-empty-item img,
|
||||
#wpadminbar #wp-admin-bar-my-account.with-avatar > a img {
|
||||
width: auto;
|
||||
height: 16px;
|
||||
@ -464,6 +470,7 @@ html:lang(he-il) .rtl #wpadminbar * {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#wpadminbar.ie8 #wp-admin-bar-my-account.with-avatar > .ab-empty-item img,
|
||||
#wpadminbar.ie8 #wp-admin-bar-my-account.with-avatar > a img {
|
||||
width: auto;
|
||||
}
|
||||
|
2
wp-includes/css/admin-bar.min.css
vendored
2
wp-includes/css/admin-bar.min.css
vendored
File diff suppressed because one or more lines are too long
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.4-alpha-34121';
|
||||
$wp_version = '4.4-alpha-34122';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
x
Reference in New Issue
Block a user