diff --git a/wp-admin/includes/class-wp-ms-users-list-table.php b/wp-admin/includes/class-wp-ms-users-list-table.php index fd71a0a494..6a4268f6ae 100644 --- a/wp-admin/includes/class-wp-ms-users-list-table.php +++ b/wp-admin/includes/class-wp-ms-users-list-table.php @@ -173,11 +173,7 @@ class WP_MS_Users_List_Table extends WP_List_Table { case 'username': $avatar = get_avatar( $user->user_email, 32 ); - if ( get_current_user_id() == $user->ID ) { - $edit_link = esc_url( network_admin_url( 'profile.php' ) ); - } else { - $edit_link = esc_url( network_admin_url( add_query_arg( 'wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), 'user-edit.php?user_id=' . $user->ID ) ) ); - } + $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) ); echo "
'; - printf( '' . __('Yes, take me to my profile page') . ' | ', admin_url('profile.php') . '#password' ); + printf( '' . __('Yes, take me to my profile page') . ' | ', get_edit_profile_url( get_current_user_id() ) . '#password' ); printf( '' . __('No thanks, do not remind me again') . '', '?default_password_nag=0' ); echo '
' . sprintf( __( 'You must be logged in to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '
', - 'logged_in_as' => '' . sprintf( __( 'Logged in as %2$s. Log out?' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '
', + 'logged_in_as' => '' . sprintf( __( 'Logged in as %2$s. Log out?' ), get_edit_user_link(), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '
', 'comment_notes_before' => '' . __( 'Your email address will not be published.' ) . ( $req ? $required_text : '' ) . '
', 'comment_notes_after' => ' ', 'id_form' => 'commentform', diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index 31bacca422..bdda370b28 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -1056,6 +1056,34 @@ function edit_bookmark_link( $link = '', $before = '', $after = '', $bookmark = echo $before . apply_filters( 'edit_bookmark_link', $link, $bookmark->link_id ) . $after; } +/** + * Retrieve edit user link + * + * @since 3.5.0 + * + * @param int $user_id Optional. User ID. Defaults to the current user. + * @return string URL to edit user page or empty string. + */ +function get_edit_user_link( $user_id = null ) { + if ( ! $user_id ) + $user_id = get_current_user_id(); + + if ( empty( $user_id ) || ! current_user_can( 'edit_user', $user_id ) ) + return ''; + + $user = new WP_User( $user_id ); + + if ( ! $user->exists() ) + return ''; + + if ( get_current_user_id() == $user->ID ) + $link = get_edit_profile_url( $user->ID ); + else + $link = add_query_arg( 'user_id', $user->ID, self_admin_url( 'user-edit.php' ) ); + + return apply_filters( 'get_edit_user_link', $link, $user->ID ); +} + // Navigation links /** diff --git a/wp-includes/theme-compat/comments-popup.php b/wp-includes/theme-compat/comments-popup.php index de4c1e9e71..79dccbef5b 100644 --- a/wp-includes/theme-compat/comments-popup.php +++ b/wp-includes/theme-compat/comments-popup.php @@ -68,7 +68,7 @@ if ( post_password_required($post) ) { // and it doesn't match the cookie