Make WordPress Core

Ticket #25162: 25162.2.diff

File 25162.2.diff, 2.4 KB (added by johnbillion, 9 years ago)
  • src/wp-includes/admin-bar.php

     
    179179function wp_admin_bar_my_account_item( $wp_admin_bar ) {
    180180        $user_id      = get_current_user_id();
    181181        $current_user = wp_get_current_user();
    182         $profile_url  = get_edit_profile_url( $user_id );
    183182
    184183        if ( ! $user_id )
    185184                return;
    186185
     186        if ( current_user_can( 'read' ) ) {
     187                $profile_url = get_edit_profile_url( $user_id );
     188        } elseif ( is_multisite() ) {
     189                $profile_url = get_dashboard_url( $user_id, 'profile.php' );
     190        } else {
     191                $profile_url = '#';
     192        }
     193
    187194        $avatar = get_avatar( $user_id, 26 );
    188195        $howdy  = sprintf( __('Howdy, %1$s'), $current_user->display_name );
    189196        $class  = empty( $avatar ) ? '' : 'with-avatar';
     
    209216function wp_admin_bar_my_account_menu( $wp_admin_bar ) {
    210217        $user_id      = get_current_user_id();
    211218        $current_user = wp_get_current_user();
    212         $profile_url  = get_edit_profile_url( $user_id );
    213219
    214220        if ( ! $user_id )
    215221                return;
    216222
     223        if ( current_user_can( 'read' ) ) {
     224                $profile_url = get_edit_profile_url( $user_id );
     225        } elseif ( is_multisite() ) {
     226                $profile_url = get_dashboard_url( $user_id, 'profile.php' );
     227        } else {
     228                $profile_url = '#';
     229        }
     230
    217231        $wp_admin_bar->add_group( array(
    218232                'parent' => 'my-account',
    219233                'id'     => 'user-actions',
     
    234248                        'tabindex' => -1,
    235249                ),
    236250        ) );
    237         $wp_admin_bar->add_menu( array(
    238                 'parent' => 'user-actions',
    239                 'id'     => 'edit-profile',
    240                 'title'  => __( 'Edit My Profile' ),
    241                 'href' => $profile_url,
    242         ) );
     251
     252        if ( '#' !== $profile_url ) {
     253                $wp_admin_bar->add_menu( array(
     254                        'parent' => 'user-actions',
     255                        'id'     => 'edit-profile',
     256                        'title'  => __( 'Edit My Profile' ),
     257                        'href'   => $profile_url,
     258                ) );
     259        }
     260
    243261        $wp_admin_bar->add_menu( array(
    244262                'parent' => 'user-actions',
    245263                'id'     => 'logout',
     
    281299        $wp_admin_bar->add_menu( array(
    282300                'id'    => 'site-name',
    283301                'title' => $title,
    284                 'href'  => is_admin() ? home_url( '/' ) : admin_url(),
     302                'href'  => ( is_admin() || ! current_user_can( 'read' ) ) ? home_url( '/' ) : admin_url(),
    285303        ) );
    286304
    287305        // Create submenu items.
     
    304322                        ) );
    305323                }
    306324
    307         } else {
     325        } else if ( current_user_can( 'read' ) ) {
    308326                // We're on the front end, link to the Dashboard.
    309327                $wp_admin_bar->add_menu( array(
    310328                        'parent' => 'site-name',