From 23a7976a4b2d12b73704acef42ce69fd87a07b31 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Fri, 23 Aug 2024 21:46:55 +0800 Subject: [PATCH] MDL-82740 core: Consider theme when checking for monologo icons --- lib/classes/component.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/classes/component.php b/lib/classes/component.php index 1346e2f160c..03591308ed5 100644 --- a/lib/classes/component.php +++ b/lib/classes/component.php @@ -25,6 +25,7 @@ namespace core; use core\exception\coding_exception; +use core\output\theme_config; use stdClass; use ArrayIterator; use DirectoryIterator; @@ -1680,11 +1681,16 @@ $cache = ' . var_export($cache, true) . '; * @return bool True if the plugin has a monologo icon */ public static function has_monologo_icon(string $plugintype, string $pluginname): bool { + global $PAGE; $plugindir = self::get_plugin_directory($plugintype, $pluginname); if ($plugindir === null) { return false; } - return file_exists("$plugindir/pix/monologo.svg") || file_exists("$plugindir/pix/monologo.png"); + $theme = theme_config::load($PAGE->theme->name); + $component = self::normalize_componentname("{$plugintype}_{$pluginname}"); + $hassvgmonologo = $theme->resolve_image_location('monologo', $component, true) !== null; + $haspngmonologo = $theme->resolve_image_location('monologo', $component) !== null; + return $haspngmonologo || $hassvgmonologo; } }