From 1e476eaf62898b5d9493b5d9f181ad4571feb713 Mon Sep 17 00:00:00 2001 From: Dennis Ploetner Date: Thu, 30 Nov 2023 11:21:44 +0100 Subject: [PATCH] Consistancy of icon type setting --- includes/MslsAdmin.php | 5 +++-- includes/MslsOptions.php | 9 +++++++++ includes/MslsPlugin.php | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/includes/MslsAdmin.php b/includes/MslsAdmin.php index af6c017f..0e45d970 100644 --- a/includes/MslsAdmin.php +++ b/includes/MslsAdmin.php @@ -156,13 +156,14 @@ public function render() { * @return string */ public function subsubsub() { - $arr = []; + $icon_type = $this->options->get_icon_type(); + $arr = []; foreach ( $this->collection->get_plugin_active_blogs() as $blog ) { $admin_url = get_admin_url( $blog->userblog_id, $this->get_options_page_link() ); $current = $blog->userblog_id == $this->collection->get_current_blog_id() ? ' class="current"' : ''; - $arr[] = sprintf( '%3$s', $admin_url, $current, $blog->get_title() ); + $arr[] = sprintf( '%3$s', $admin_url, $current, $blog->get_title( $icon_type ) ); } return empty( $arr ) ? '' : sprintf( '', implode( ' |
  • ', $arr ) ); diff --git a/includes/MslsOptions.php b/includes/MslsOptions.php index 0abff15c..a2902d8e 100644 --- a/includes/MslsOptions.php +++ b/includes/MslsOptions.php @@ -422,4 +422,13 @@ public static function check_for_blog_slug( $url, $options ) { return home_url( $url ); } + /** + * Get the icon type by the settings saved in admin_display + * + * @return string + */ + public function get_icon_type(): string { + return MslsAdminIcon::TYPE_LABEL === $this->admin_display ? MslsAdminIcon::TYPE_LABEL : MslsAdminIcon::TYPE_FLAG; + } + } diff --git a/includes/MslsPlugin.php b/includes/MslsPlugin.php index ed055470..15f88bcf 100644 --- a/includes/MslsPlugin.php +++ b/includes/MslsPlugin.php @@ -121,7 +121,7 @@ public static function get_output() { * @return void */ public static function update_adminbar( \WP_Admin_Bar $wp_admin_bar ): void { - $icon_type = MslsAdminIcon::TYPE_LABEL === MslsOptions::instance()->admin_display ? MslsAdminIcon::TYPE_LABEL : MslsAdminIcon::TYPE_FLAG; + $icon_type = MslsOptions::instance()->get_icon_type(); $blog_collection = MslsBlogCollection::instance(); foreach ( $blog_collection->get_plugin_active_blogs() as $blog ) {