Make WordPress Core


Ignore:
Timestamp:
09/27/2016 07:00:35 PM (8 years ago)
Author:
ocean90
Message:

Toolbar: Update links to the about page if current user can't access the dashboard of the current site.

Add missing focus styling for menu items with an icon.

Fixes #37949.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/admin-bar.php

    r38634 r38660  
    108108 */
    109109function wp_admin_bar_wp_menu( $wp_admin_bar ) {
    110     $wp_admin_bar->add_menu( array(
     110    if ( current_user_can( 'read' ) ) {
     111        $about_url = self_admin_url( 'about.php' );
     112    } elseif ( is_multisite() ) {
     113        $about_url = get_dashboard_url( get_current_user_id(), 'about.php' );
     114    } else {
     115        $about_url = false;
     116    }
     117
     118    $wp_logo_menu_args = array(
    111119        'id'    => 'wp-logo',
    112120        'title' => '<span class="ab-icon"></span><span class="screen-reader-text">' . __( 'About WordPress' ) . '</span>',
    113         'href'  => self_admin_url( 'about.php' ),
    114     ) );
    115 
    116     if ( is_user_logged_in() ) {
     121        'href'  => $about_url,
     122    );
     123
     124    // Set tabindex="0" to make sub menus accessible when no URL is available.
     125    if ( ! $about_url ) {
     126        $wp_logo_menu_args['meta'] = array(
     127            'tabindex' => 0,
     128        );
     129    }
     130
     131    $wp_admin_bar->add_menu( $wp_logo_menu_args );
     132
     133    if ( $about_url ) {
    117134        // Add "About WordPress" link
    118135        $wp_admin_bar->add_menu( array(
     
    120137            'id'     => 'about',
    121138            'title'  => __('About WordPress'),
    122             'href'   => self_admin_url( 'about.php' ),
     139            'href'   => $about_url,
    123140        ) );
    124141    }
     
    295312
    296313    if ( is_network_admin() ) {
    297         /* translators: %s: site name */ 
     314        /* translators: %s: site name */
    298315        $blogname = sprintf( __( 'Network Admin: %s' ), esc_html( get_current_site()->site_name ) );
    299316    } elseif ( is_user_admin() ) {
    300         /* translators: %s: site name */ 
     317        /* translators: %s: site name */
    301318        $blogname = sprintf( __( 'User Dashboard: %s' ), esc_html( get_current_site()->site_name ) );
    302319    }
Note: See TracChangeset for help on using the changeset viewer.