From 63798ce3210b80a27dda5e0acf91b92f45ff6dba Mon Sep 17 00:00:00 2001 From: Dennis Ploetner Date: Fri, 29 Sep 2023 07:32:05 +0200 Subject: [PATCH] Blavatar functionallity fixed --- includes/MslsBlog.php | 23 +++++++++++++++++++++++ includes/MslsPlugin.php | 6 ++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/includes/MslsBlog.php b/includes/MslsBlog.php index 2b9023a6..f9bfb9d6 100644 --- a/includes/MslsBlog.php +++ b/includes/MslsBlog.php @@ -171,4 +171,27 @@ public static function description( MslsBlog $a, MslsBlog $b ) { return self::_cmp( $a->get_description(), $b->get_description() ); } + /** + * @return string + */ + public function get_blavatar(): string { + $blavatar_html = '
'; + $show_site_icons = apply_filters( 'wp_admin_bar_show_site_icons', true ); + + switch_to_blog( $this->obj->userblog_id ); + + if ( true === $show_site_icons && has_site_icon( $this->obj->userblog_id ) ) { + $blavatar_html = sprintf( + '', + esc_url( get_site_icon_url( 16 ) ), + esc_url( get_site_icon_url( 32 ) ), + ( wp_lazy_loading_enabled( 'img', 'site_icon_in_toolbar' ) ? ' loading="lazy"' : '' ) + ); + } + + restore_current_blog(); + + return $blavatar_html; + } + } diff --git a/includes/MslsPlugin.php b/includes/MslsPlugin.php index ee004f09..29f7694e 100644 --- a/includes/MslsPlugin.php +++ b/includes/MslsPlugin.php @@ -117,11 +117,13 @@ public static function get_output() { /** * @param $wp_admin_bar + * + * @return void */ - public static function update_adminbar( \WP_Admin_Bar $wp_admin_bar ) { + public static function update_adminbar( \WP_Admin_Bar $wp_admin_bar ): void { $blog_collection = MslsBlogCollection::instance(); foreach ( $blog_collection->get_plugin_active_blogs() as $blog ) { - $title = '
' . $blog->get_title(); + $title = $blog->get_blavatar() . $blog->get_title(); $wp_admin_bar->add_node( [ 'id' => 'blog-' . $blog->userblog_id, 'title' => $title ] ); }