From 40aed04ae1159520d7ecb607ecfe20f4d42fff10 Mon Sep 17 00:00:00 2001 From: raortegar Date: Fri, 12 Apr 2024 17:02:50 +0200 Subject: [PATCH] MDL-81512 core_theme: Use admin_settingpage for theme settings This also moves any theme settings pages to the themes category instead of "appearance", so they remain where expected, and avoids adding to that section if the theme is hidden (so if there are no custom theme settings, that section will not appear on the page). Co-authored-by: Michael Hawkins --- admin/settings/appearance.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/admin/settings/appearance.php b/admin/settings/appearance.php index 00feea8cc40..56b1c0724c8 100644 --- a/admin/settings/appearance.php +++ b/admin/settings/appearance.php @@ -353,11 +353,13 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) { // sp foreach (core_component::get_plugin_list('theme') as $theme => $themedir) { $settingspath = "$themedir/settings.php"; if (file_exists($settingspath)) { - $settings = new admin_externalpage('themesetting' . $theme, new lang_string('pluginname', 'theme_'.$theme), - new moodle_url($settingspath), 'moodle/site:config', true); + $settings = new admin_settingpage("themesetting$theme", new lang_string('pluginname', "theme_$theme"), + 'moodle/site:config', true + ); include($settingspath); - if ($settings) { - $ADMIN->add('appearance', $settings); + // Add settings if not hidden (to avoid displaying the section if it appears empty in the UI). + if ($settings && !$settings->hidden) { + $ADMIN->add('themes', $settings); } } }