Skip to content

Commit 1aff021

Browse files
committed
[REVERT] Toolbar: Show the site icon in the admin bar when one is set.
Reverts #62614. The patch proposes accidentally undid changes from #62592 and #62543. See #62614. git-svn-id: https://develop.svn.wordpress.org/trunk@62620 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 27deb59 commit 1aff021

3 files changed

Lines changed: 14 additions & 153 deletions

File tree

src/wp-includes/admin-bar.php

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ function wp_admin_bar_my_account_item( $wp_admin_bar ) {
276276
/* translators: %s: Current user's display name. */
277277
$howdy = sprintf( __( 'Howdy, %s' ), '<span class="display-name">' . wp_get_current_user()->display_name . '</span>' );
278278

279-
$avatar = get_avatar( $user_id, 26 );
279+
$avatar = get_avatar( $user_id, 28 );
280280
$wp_admin_bar->add_node(
281281
array(
282282
'id' => 'my-account',
@@ -385,32 +385,15 @@ function wp_admin_bar_site_menu( $wp_admin_bar ) {
385385
}
386386

387387
$title = wp_html_excerpt( $blogname, 40, '&hellip;' );
388-
$meta = array(
389-
'menu_title' => $title,
390-
);
391-
392-
if ( ! is_network_admin() && ! is_user_admin() ) {
393-
/** This filter is documented in wp-includes/admin-bar.php */
394-
$show_site_icons = apply_filters( 'wp_admin_bar_show_site_icons', true );
395-
396-
if ( true === $show_site_icons && has_site_icon() ) {
397-
$site_icon = sprintf(
398-
'<img class="site-icon" src="%s" srcset="%s 2x" alt="" width="20" height="20" />',
399-
esc_url( get_site_icon_url( 32 ) ),
400-
esc_url( get_site_icon_url( 64 ) )
401-
);
402-
403-
$title = $site_icon . $title;
404-
$meta['class'] = 'has-site-icon';
405-
}
406-
}
407388

408389
$wp_admin_bar->add_node(
409390
array(
410391
'id' => 'site-name',
411392
'title' => $title,
412393
'href' => ( is_admin() || ! current_user_can( 'read' ) ) ? home_url( '/' ) : admin_url(),
413-
'meta' => $meta,
394+
'meta' => array(
395+
'menu_title' => $title,
396+
),
414397
)
415398
);
416399

src/wp-includes/css/admin-bar.css

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ html:lang(he-il) .rtl #wpadminbar * {
455455
top: 4px;
456456
width: 64px;
457457
height: 64px;
458+
border-radius: 50%;
458459
}
459460

460461
#wpadminbar #wp-admin-bar-user-info a {
@@ -481,9 +482,10 @@ html:lang(he-il) .rtl #wpadminbar * {
481482
#wpadminbar #wp-admin-bar-my-account.with-avatar > .ab-empty-item img,
482483
#wpadminbar #wp-admin-bar-my-account.with-avatar > a img {
483484
width: auto;
484-
height: 16px;
485+
height: 20px;
485486
padding: 0;
486-
border: 1px solid #8c8f94;
487+
border: 1px solid #2c353b;
488+
border-radius: 50%;
487489
background: #f0f0f1;
488490
line-height: 1.84615384;
489491
vertical-align: middle;
@@ -537,10 +539,6 @@ html:lang(he-il) .rtl #wpadminbar * {
537539
margin: 0 8px 2px -2px;
538540
}
539541

540-
#wpadminbar .quicklinks li img.blavatar {
541-
border-radius: 2px;
542-
}
543-
544542
#wpadminbar .quicklinks li div.blavatar:before {
545543
content: "\f120";
546544
content: "\f120" / '';
@@ -586,23 +584,6 @@ html:lang(he-il) .rtl #wpadminbar * {
586584
content: "\f102" / '';
587585
}
588586

589-
#wpadminbar #wp-admin-bar-site-name.has-site-icon > .ab-item {
590-
display: flex;
591-
align-items: center;
592-
gap: 6px;
593-
}
594-
595-
#wpadminbar #wp-admin-bar-site-name.has-site-icon > .ab-item:before {
596-
content: none;
597-
}
598-
599-
#wpadminbar #wp-admin-bar-site-name > .ab-item .site-icon {
600-
width: 20px;
601-
height: 20px;
602-
background: #f0f0f1; /* matching my-account (user avatar) node's background */
603-
border-radius: 2px;
604-
}
605-
606587

607588

608589
/**
@@ -924,7 +905,7 @@ html:lang(he-il) .rtl #wpadminbar * {
924905

925906
#wpadminbar #wp-admin-bar-edit > .ab-item:before,
926907
#wpadminbar #wp-admin-bar-my-sites > .ab-item:before,
927-
#wpadminbar #wp-admin-bar-site-name:not(.has-site-icon) > .ab-item:before,
908+
#wpadminbar #wp-admin-bar-site-name > .ab-item:before,
928909
#wpadminbar #wp-admin-bar-site-editor > .ab-item:before,
929910
#wpadminbar #wp-admin-bar-customize > .ab-item:before,
930911
#wpadminbar #wp-admin-bar-my-account > .ab-item:before,
@@ -939,16 +920,6 @@ html:lang(he-il) .rtl #wpadminbar * {
939920
-moz-osx-font-smoothing: grayscale;
940921
}
941922

942-
#wpadminbar #wp-admin-bar-site-name > .ab-item .site-icon {
943-
position: absolute;
944-
top: 9px;
945-
left: 12px;
946-
width: 28px;
947-
height: 28px;
948-
margin: 0;
949-
border-radius: 4px;
950-
}
951-
952923
#wpadminbar #wp-admin-bar-appearance {
953924
margin-top: 0;
954925
}
@@ -1000,18 +971,19 @@ html:lang(he-il) .rtl #wpadminbar * {
1000971
#wpadminbar #wp-admin-bar-my-account > a {
1001972
position: relative;
1002973
white-space: nowrap;
1003-
text-indent: 150%; /* More than 100% indention is needed since this element has padding */
974+
text-indent: 150%; /* More than 100% indentation is needed since this element has padding */
1004975
width: 28px;
1005976
padding: 0 10px;
1006977
overflow: hidden; /* Prevent link text from forcing horizontal scrolling on mobile */
1007978
}
1008979

1009980
#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img {
1010981
position: absolute;
1011-
top: 13px;
982+
top: 12px;
1012983
right: 10px;
1013-
width: 26px;
1014-
height: 26px;
984+
width: 28px;
985+
height: 28px;
986+
border-radius: 50%;
1015987
}
1016988

1017989
#wpadminbar #wp-admin-bar-user-actions.ab-submenu {

tests/phpunit/tests/adminbar.php

Lines changed: 0 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -810,100 +810,6 @@ public function data_my_sites_network_menu_items() {
810810
);
811811
}
812812

813-
/**
814-
* @covers ::wp_admin_bar_site_menu
815-
*/
816-
public function test_site_name_menu_has_no_site_icon_when_unset() {
817-
wp_set_current_user( self::$editor_id );
818-
819-
$wp_admin_bar = $this->get_standard_admin_bar();
820-
$node_site_name = $wp_admin_bar->get_node( 'site-name' );
821-
822-
$this->assertStringNotContainsString( 'site-icon', $node_site_name->title );
823-
$this->assertArrayNotHasKey( 'class', $node_site_name->meta );
824-
}
825-
826-
/**
827-
* @covers ::wp_admin_bar_site_menu
828-
* @requires function imagejpeg
829-
*/
830-
public function test_site_name_menu_includes_site_icon_when_set() {
831-
wp_set_current_user( self::$editor_id );
832-
833-
$attachment_id = self::factory()->attachment->create_upload_object( DIR_TESTDATA . '/images/test-image.jpg' );
834-
update_option( 'site_icon', $attachment_id );
835-
836-
$wp_admin_bar = $this->get_standard_admin_bar();
837-
$node_site_name = $wp_admin_bar->get_node( 'site-name' );
838-
839-
$this->assertStringContainsString( '<img class="site-icon"', $node_site_name->title );
840-
$this->assertStringContainsString( esc_url( get_site_icon_url( 32 ) ), $node_site_name->title );
841-
$this->assertSame( 'has-site-icon', $node_site_name->meta['class'] );
842-
}
843-
844-
/**
845-
* @covers ::wp_admin_bar_site_menu
846-
* @requires function imagejpeg
847-
*/
848-
public function test_site_name_menu_respects_show_site_icons_filter() {
849-
wp_set_current_user( self::$editor_id );
850-
851-
$attachment_id = self::factory()->attachment->create_upload_object( DIR_TESTDATA . '/images/test-image.jpg' );
852-
update_option( 'site_icon', $attachment_id );
853-
854-
add_filter( 'wp_admin_bar_show_site_icons', '__return_false' );
855-
856-
$wp_admin_bar = $this->get_standard_admin_bar();
857-
$node_site_name = $wp_admin_bar->get_node( 'site-name' );
858-
859-
$this->assertStringNotContainsString( 'site-icon', $node_site_name->title );
860-
$this->assertArrayNotHasKey( 'class', $node_site_name->meta );
861-
}
862-
863-
/**
864-
* @covers ::wp_admin_bar_site_menu
865-
* @group multisite
866-
* @group ms-required
867-
* @requires function imagejpeg
868-
*/
869-
public function test_site_name_menu_has_no_site_icon_in_network_admin() {
870-
wp_set_current_user( self::$admin_id );
871-
872-
$attachment_id = self::factory()->attachment->create_upload_object( DIR_TESTDATA . '/images/test-image.jpg' );
873-
update_option( 'site_icon', $attachment_id );
874-
875-
set_current_screen( 'dashboard-network' );
876-
877-
$wp_admin_bar = $this->get_standard_admin_bar();
878-
$node_site_name = $wp_admin_bar->get_node( 'site-name' );
879-
880-
$this->assertTrue( is_network_admin() );
881-
$this->assertStringNotContainsString( 'site-icon', $node_site_name->title );
882-
$this->assertArrayNotHasKey( 'class', $node_site_name->meta );
883-
}
884-
885-
/**
886-
* @covers ::wp_admin_bar_site_menu
887-
* @group multisite
888-
* @group ms-required
889-
* @requires function imagejpeg
890-
*/
891-
public function test_site_name_menu_has_no_site_icon_in_user_admin() {
892-
wp_set_current_user( self::$admin_id );
893-
894-
$attachment_id = self::factory()->attachment->create_upload_object( DIR_TESTDATA . '/images/test-image.jpg' );
895-
update_option( 'site_icon', $attachment_id );
896-
897-
set_current_screen( 'dashboard-user' );
898-
899-
$wp_admin_bar = $this->get_standard_admin_bar();
900-
$node_site_name = $wp_admin_bar->get_node( 'site-name' );
901-
902-
$this->assertTrue( is_user_admin() );
903-
$this->assertStringNotContainsString( 'site-icon', $node_site_name->title );
904-
$this->assertArrayNotHasKey( 'class', $node_site_name->meta );
905-
}
906-
907813
/**
908814
* This test ensures that WP_Admin_Bar::$proto is not defined (including magic methods).
909815
*

0 commit comments

Comments
 (0)