Fix to only enable theme switcher in debug mode

This commit is contained in:
Ilia Ross
2023-09-29 12:56:23 +03:00
parent 5c54c614e3
commit 9a1e869a82
2 changed files with 5 additions and 1 deletions

View File

@ -12,6 +12,9 @@ my $err = sub {
print("<tt>Cannot change theme : $_[0]</tt>\n"); print("<tt>Cannot change theme : $_[0]</tt>\n");
exit(1); exit(1);
}; };
# Check if in debug mode
&$err("Debug mode is not enabled!")
if (!$gconfig{'error_stack'} && !$gconfig{'debug_enabled'});
# Check if allowed to change theme, # Check if allowed to change theme,
# otherwise throw an error # otherwise throw an error
if (!&foreign_available('theme') && if (!&foreign_available('theme') &&

View File

@ -2299,7 +2299,8 @@ Hotkeys are:
sub ui_switch_theme_javascript sub ui_switch_theme_javascript
{ {
return &theme_ui_switch_theme_javascript(@_) if (defined(&theme_ui_switch_theme_javascript)); return &theme_ui_switch_theme_javascript(@_) if (defined(&theme_ui_switch_theme_javascript));
my $switch_script = "<script>const __webmin_webprefix__ = '@{[&get_webprefix()]}';</script>"; return "" if (!$gconfig{'error_stack'} && !$gconfig{'debug_enabled'});
my $switch_script = "<script>const __webmin_webprefix__ = '@{[&get_webprefix()]}';</script>\n";
$switch_script .= "<script type=\"text/javascript\" src=\"@{[&get_webprefix()]}/unauthenticated/switch_theme.js?@{[&get_webmin_version(1)]}\"></script>\n"; $switch_script .= "<script type=\"text/javascript\" src=\"@{[&get_webprefix()]}/unauthenticated/switch_theme.js?@{[&get_webmin_version(1)]}\"></script>\n";
return $switch_script; return $switch_script;
} }