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. git-svn-id: https://develop.svn.wordpress.org/trunk@38660 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
8fcec07595
commit
0bab64c370
|
@ -324,6 +324,7 @@ ul#adminmenu > li.current > a.current:after {
|
||||||
#wpadminbar li:hover .ab-item:before,
|
#wpadminbar li:hover .ab-item:before,
|
||||||
#wpadminbar li a:focus .ab-icon:before,
|
#wpadminbar li a:focus .ab-icon:before,
|
||||||
#wpadminbar li .ab-item:focus:before,
|
#wpadminbar li .ab-item:focus:before,
|
||||||
|
#wpadminbar li .ab-item:focus .ab-icon:before,
|
||||||
#wpadminbar li.hover .ab-icon:before,
|
#wpadminbar li.hover .ab-icon:before,
|
||||||
#wpadminbar li.hover .ab-item:before,
|
#wpadminbar li.hover .ab-item:before,
|
||||||
#wpadminbar li:hover #adminbarsearch:before,
|
#wpadminbar li:hover #adminbarsearch:before,
|
||||||
|
|
|
@ -107,19 +107,36 @@ function wp_admin_bar_render() {
|
||||||
* @param WP_Admin_Bar $wp_admin_bar
|
* @param WP_Admin_Bar $wp_admin_bar
|
||||||
*/
|
*/
|
||||||
function wp_admin_bar_wp_menu( $wp_admin_bar ) {
|
function wp_admin_bar_wp_menu( $wp_admin_bar ) {
|
||||||
$wp_admin_bar->add_menu( array(
|
if ( current_user_can( 'read' ) ) {
|
||||||
|
$about_url = self_admin_url( 'about.php' );
|
||||||
|
} elseif ( is_multisite() ) {
|
||||||
|
$about_url = get_dashboard_url( get_current_user_id(), 'about.php' );
|
||||||
|
} else {
|
||||||
|
$about_url = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$wp_logo_menu_args = array(
|
||||||
'id' => 'wp-logo',
|
'id' => 'wp-logo',
|
||||||
'title' => '<span class="ab-icon"></span><span class="screen-reader-text">' . __( 'About WordPress' ) . '</span>',
|
'title' => '<span class="ab-icon"></span><span class="screen-reader-text">' . __( 'About WordPress' ) . '</span>',
|
||||||
'href' => self_admin_url( 'about.php' ),
|
'href' => $about_url,
|
||||||
) );
|
);
|
||||||
|
|
||||||
if ( is_user_logged_in() ) {
|
// Set tabindex="0" to make sub menus accessible when no URL is available.
|
||||||
|
if ( ! $about_url ) {
|
||||||
|
$wp_logo_menu_args['meta'] = array(
|
||||||
|
'tabindex' => 0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$wp_admin_bar->add_menu( $wp_logo_menu_args );
|
||||||
|
|
||||||
|
if ( $about_url ) {
|
||||||
// Add "About WordPress" link
|
// Add "About WordPress" link
|
||||||
$wp_admin_bar->add_menu( array(
|
$wp_admin_bar->add_menu( array(
|
||||||
'parent' => 'wp-logo',
|
'parent' => 'wp-logo',
|
||||||
'id' => 'about',
|
'id' => 'about',
|
||||||
'title' => __('About WordPress'),
|
'title' => __('About WordPress'),
|
||||||
'href' => self_admin_url( 'about.php' ),
|
'href' => $about_url,
|
||||||
) );
|
) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -294,6 +294,7 @@ html:lang(he-il) .rtl #wpadminbar * {
|
||||||
#wpadminbar li:hover .ab-item:before,
|
#wpadminbar li:hover .ab-item:before,
|
||||||
#wpadminbar li a:focus .ab-icon:before,
|
#wpadminbar li a:focus .ab-icon:before,
|
||||||
#wpadminbar li .ab-item:focus:before,
|
#wpadminbar li .ab-item:focus:before,
|
||||||
|
#wpadminbar li .ab-item:focus .ab-icon:before,
|
||||||
#wpadminbar li.hover .ab-icon:before,
|
#wpadminbar li.hover .ab-icon:before,
|
||||||
#wpadminbar li.hover .ab-item:before,
|
#wpadminbar li.hover .ab-item:before,
|
||||||
#wpadminbar li:hover #adminbarsearch:before,
|
#wpadminbar li:hover #adminbarsearch:before,
|
||||||
|
|
|
@ -407,4 +407,28 @@ class Tests_AdminBar extends WP_UnitTestCase {
|
||||||
|
|
||||||
$this->assertNull( $node );
|
$this->assertNull( $node );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ticket 37949
|
||||||
|
*/
|
||||||
|
public function test_admin_bar_does_not_add_about_page_url() {
|
||||||
|
wp_set_current_user( self::$no_role_id );
|
||||||
|
|
||||||
|
$wp_admin_bar = $this->get_standard_admin_bar();
|
||||||
|
$node = $wp_admin_bar->get_node( 'wp-logo' );
|
||||||
|
|
||||||
|
$this->assertNotNull( $node );
|
||||||
|
$this->assertSame( false, $node->href );
|
||||||
|
$this->assertArrayHasKey( 'tabindex', $node->meta );
|
||||||
|
$this->assertSame( 0, $node->meta['tabindex'] );
|
||||||
|
|
||||||
|
wp_set_current_user( self::$editor_id );
|
||||||
|
|
||||||
|
$wp_admin_bar = $this->get_standard_admin_bar();
|
||||||
|
$node = $wp_admin_bar->get_node( 'wp-logo' );
|
||||||
|
|
||||||
|
$this->assertNotNull( $node );
|
||||||
|
$this->assertSame( admin_url( 'about.php' ), $node->href );
|
||||||
|
$this->assertArrayNotHasKey( 'tabindex', $node->meta );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue