Skip to content

Commit c6c4134

Browse files
committed
Toolbar: Add View User and Edit User links to the admin toolbar to ease navigation between a user's archives and the user editing screen.
Props georgestephanis, lessbloat, johnbillion Fixes #20307 git-svn-id: https://develop.svn.wordpress.org/trunk@41159 602fd350-edb4-49c9-b593-d223f7449a82
1 parent e6028d9 commit c6c4134

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

src/wp-includes/admin-bar.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ function wp_admin_bar_shortlink_menu( $wp_admin_bar ) {
598598
* @param WP_Admin_Bar $wp_admin_bar
599599
*/
600600
function wp_admin_bar_edit_menu( $wp_admin_bar ) {
601-
global $tag, $wp_the_query;
601+
global $tag, $wp_the_query, $user_id;
602602

603603
if ( is_admin() ) {
604604
$current_screen = get_current_screen();
@@ -648,6 +648,17 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) {
648648
'title' => $tax->labels->view_item,
649649
'href' => get_term_link( $tag )
650650
) );
651+
} elseif ( 'user-edit' == $current_screen->base
652+
&& isset( $user_id )
653+
&& ( $user_object = get_userdata( $user_id ) )
654+
&& $user_object->exists()
655+
&& $view_link = get_author_posts_url( $user_object->ID ) )
656+
{
657+
$wp_admin_bar->add_menu( array(
658+
'id' => 'view',
659+
'title' => __( 'View User' ),
660+
'href' => $view_link,
661+
) );
651662
}
652663
} else {
653664
$current_object = $wp_the_query->get_queried_object();
@@ -676,6 +687,15 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) {
676687
'title' => $tax->labels->edit_item,
677688
'href' => $edit_term_link
678689
) );
690+
} elseif ( is_a( $current_object, 'WP_User' )
691+
&& current_user_can( 'edit_user', $current_object->ID )
692+
&& $edit_user_link = get_edit_user_link( $current_object->ID ) )
693+
{
694+
$wp_admin_bar->add_menu( array(
695+
'id' => 'edit',
696+
'title' => __( 'Edit User' ),
697+
'href' => $edit_user_link,
698+
) );
679699
}
680700
}
681701
}

0 commit comments

Comments
 (0)