From be94fa5483dd98667d1fd911d6390ad34387804d Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Wed, 26 Jul 2017 16:45:44 +0000 Subject: [PATCH] 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 --- wp-includes/admin-bar.php | 22 +++++++++++++++++++++- wp-includes/version.php | 2 +- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/wp-includes/admin-bar.php b/wp-includes/admin-bar.php index 7ff55febe2..4bd49ed89a 100644 --- a/wp-includes/admin-bar.php +++ b/wp-includes/admin-bar.php @@ -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, + ) ); } } } diff --git a/wp-includes/version.php b/wp-includes/version.php index 437cc441ac..61489ef055 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.