WordPress.org

Make WordPress Core

Ticket #46657: 46657.2.diff

File 46657.2.diff, 1.5 KB (added by rmccue, 14 months ago)

Add filter to allow custom site icons

  • src/wp-includes/admin-bar.php

    diff --git src/wp-includes/admin-bar.php src/wp-includes/admin-bar.php
    index 6600c651df..30b67713a0 100644
    function wp_admin_bar_my_sites_menu( $wp_admin_bar ) { 
    569569        foreach ( (array) $wp_admin_bar->user->blogs as $blog ) {
    570570                switch_to_blog( $blog->userblog_id );
    571571
    572                 $blavatar = '<div class="blavatar"></div>';
     572                $icon_url = get_site_icon_url( 16 );
     573                if ( $icon_url ) {
     574                        $blavatar = sprintf(
     575                                '<img src="%s" class="blavatar" width="16" height="16" />',
     576                                $icon_url
     577                        );
     578                } else {
     579                        $blavatar = '<div class="blavatar"></div>';
     580                }
     581
     582                /**
     583                 * Filter the icon for a site in the My Sites dropdown menu.
     584                 *
     585                 * @param string $blavatar Site icon markup.
     586                 * @param stdClass $blog Site being displayed.
     587                 */
     588                $blavatar = apply_filters( 'admin_bar_my_sites_site_icon', $blavatar, $blog );
    573589
    574590                $blogname = $blog->blogname;
    575591
  • src/wp-includes/css/admin-bar.css

    diff --git src/wp-includes/css/admin-bar.css src/wp-includes/css/admin-bar.css
    index ae35741489..f6dae56189 100644
    html:lang(he-il) .rtl #wpadminbar * { 
    511511        color: #eee;
    512512}
    513513
     514#wpadminbar .quicklinks li img.blavatar {
     515        height: 16px;
     516        width: 16px;
     517        display: inline-block;
     518        margin: 6px 8px 0 -2px;
     519}
     520
    514521#wpadminbar .quicklinks li a:hover .blavatar,
    515522#wpadminbar .quicklinks li a:focus .blavatar,
    516523#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a .blavatar {