WordPress.org

Make WordPress Core

Changeset 38660


Ignore:
Timestamp:
09/27/2016 07:00:35 PM (5 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.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/css/colors/_admin.scss

    r38638 r38660  
    325325#wpadminbar li a:focus .ab-icon:before,
    326326#wpadminbar li .ab-item:focus:before,
     327#wpadminbar li .ab-item:focus .ab-icon:before,
    327328#wpadminbar li.hover .ab-icon:before,
    328329#wpadminbar li.hover .ab-item:before,
  • 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    }
  • trunk/src/wp-includes/css/admin-bar.css

    r38152 r38660  
    295295#wpadminbar li a:focus .ab-icon:before,
    296296#wpadminbar li .ab-item:focus:before,
     297#wpadminbar li .ab-item:focus .ab-icon:before,
    297298#wpadminbar li.hover .ab-icon:before,
    298299#wpadminbar li.hover .ab-item:before,
  • trunk/tests/phpunit/tests/adminbar.php

    r38634 r38660  
    408408        $this->assertNull( $node );
    409409    }
     410
     411    /**
     412     * @ticket 37949
     413     */
     414    public function test_admin_bar_does_not_add_about_page_url() {
     415        wp_set_current_user( self::$no_role_id );
     416
     417        $wp_admin_bar = $this->get_standard_admin_bar();
     418        $node         = $wp_admin_bar->get_node( 'wp-logo' );
     419
     420        $this->assertNotNull( $node );
     421        $this->assertSame( false, $node->href );
     422        $this->assertArrayHasKey( 'tabindex', $node->meta );
     423        $this->assertSame( 0, $node->meta['tabindex'] );
     424
     425        wp_set_current_user( self::$editor_id );
     426
     427        $wp_admin_bar = $this->get_standard_admin_bar();
     428        $node         = $wp_admin_bar->get_node( 'wp-logo' );
     429
     430        $this->assertNotNull( $node );
     431        $this->assertSame( admin_url( 'about.php' ), $node->href );
     432        $this->assertArrayNotHasKey( 'tabindex', $node->meta );
     433    }
    410434}
Note: See TracChangeset for help on using the changeset viewer.