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

Built from https://develop.svn.wordpress.org/trunk@41159


git-svn-id: http://core.svn.wordpress.org/trunk@40999 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
John Blackbourn 2017-07-26 16:45:44 +00:00
parent 6b22dbe59a
commit be94fa5483
2 changed files with 22 additions and 2 deletions

View File

@ -598,7 +598,7 @@ function wp_admin_bar_shortlink_menu( $wp_admin_bar ) {
* @param WP_Admin_Bar $wp_admin_bar
*/
function wp_admin_bar_edit_menu( $wp_admin_bar ) {
global $tag, $wp_the_query;
global $tag, $wp_the_query, $user_id;
if ( is_admin() ) {
$current_screen = get_current_screen();
@ -648,6 +648,17 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) {
'title' => $tax->labels->view_item,
'href' => get_term_link( $tag )
) );
} elseif ( 'user-edit' == $current_screen->base
&& isset( $user_id )
&& ( $user_object = get_userdata( $user_id ) )
&& $user_object->exists()
&& $view_link = get_author_posts_url( $user_object->ID ) )
{
$wp_admin_bar->add_menu( array(
'id' => 'view',
'title' => __( 'View User' ),
'href' => $view_link,
) );
}
} else {
$current_object = $wp_the_query->get_queried_object();
@ -676,6 +687,15 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) {
'title' => $tax->labels->edit_item,
'href' => $edit_term_link
) );
} elseif ( is_a( $current_object, 'WP_User' )
&& current_user_can( 'edit_user', $current_object->ID )
&& $edit_user_link = get_edit_user_link( $current_object->ID ) )
{
$wp_admin_bar->add_menu( array(
'id' => 'edit',
'title' => __( 'Edit User' ),
'href' => $edit_user_link,
) );
}
}
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.9-alpha-41158';
$wp_version = '4.9-alpha-41159';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.