WordPress.org

Make WordPress Core

Opened 10 months ago

Last modified 10 months ago

#46657 new enhancement

Show site icon in My Sites admin menu

Reported by: rmccue Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 4.3
Component: Administration Keywords: has-patch needs-testing
Focuses: multisite Cc:
PR Number:

Description

The My Sites menu shows a WordPress logo next to every site. This isn't super useful, as you end up with a list full of WordPress icons.

This feature appears to have been modelled originally on WordPress.com's "blavatar" feature (and the class is named thus as well). However on WordPress.com, the site's icon is used instead of a generic WordPress icon.

With site icons in WordPress core, we should use these instead.

Attachments (4)

46657.diff (1.2 KB) - added by rmccue 10 months ago.
Initial proof-of-concept
46657.2.diff (1.5 KB) - added by rmccue 10 months ago.
Add filter to allow custom site icons
46657.3.diff (1.5 KB) - added by rmccue 10 months ago.
Escape URL before output
46657.4.diff (1.6 KB) - added by rmccue 10 months ago.
Add alt and update CSS

Download all attachments as: .zip

Change History (12)

@rmccue
10 months ago

Initial proof-of-concept

#1 @rmccue
10 months ago

  • Keywords has-patch added
  • Version set to 4.3

@rmccue
10 months ago

Add filter to allow custom site icons

#2 @rmccue
10 months ago

46657.2.diff adds the site icon in place of the default WordPress logo. This replaces the <div class="blavatar"></div> with <img src="..." class="blavatar" /> if the site has an icon.

For example, with a site with an icon and one without:

https://i.imgur.com/bumICpf.png

#3 @desrosj
10 months ago

Related: #33573.

#4 @joemcgill
10 months ago

@rmccue I'd suggest using esc_url() here. It's best practice—particularly since the output of that function is filterable so the value can't be trusted—and would be consistent with other places in core where get_site_icon_url() is used.

See examples:

@rmccue
10 months ago

Escape URL before output

#5 @rmccue
10 months ago

46657.3.diff uses esc_url, and also uses string concatenation to better match core's general style.

#6 @afercia
10 months ago

Cool.

For better accessibility, the image needs an empty alt="" attribute, otherwise screen readers will announce the image filename.

CSS:

  • the image inherits float: left so display: inline-block doesn't do anything
  • .blavatar:before targets also the image: I'd suggest to add a rule to target img.blavatar:before and reset the content property to content: none

@rmccue
10 months ago

Add alt and update CSS

#7 @rmccue
10 months ago

Thanks @afercia!

46657.4.diff adds the alt and reworks the CSS to keep it DRY and avoid a (nonsense) img:before rule.

#8 @desrosj
10 months ago

  • Keywords needs-testing added
  • Milestone changed from Awaiting Review to Future Release
Note: See TracTickets for help on using tickets.