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 <[email protected]>
This commit is contained in:
raortegar
2024-04-16 17:43:46 +08:00
committed by Michael Hawkins
co-authored by Michael Hawkins
parent 57df4a1dbb
commit 40aed04ae1
+6 -4
View File
@@ -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);
}
}
}