From f39dcb432e704c846295cbd62a1374cd5ab34beb Mon Sep 17 00:00:00 2001 From: jdarwood007 Date: Sat, 31 Jan 2026 12:12:13 -0800 Subject: [PATCH] [3.0] Add missing support for variant settings for members Pulled from #7933 --- Sources/Actions/Profile/ThemeOptions.php | 45 ++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/Sources/Actions/Profile/ThemeOptions.php b/Sources/Actions/Profile/ThemeOptions.php index 5d397a6338..c21fa9aded 100644 --- a/Sources/Actions/Profile/ThemeOptions.php +++ b/Sources/Actions/Profile/ThemeOptions.php @@ -43,6 +43,51 @@ public function execute(): void Theme::loadTemplate('Settings'); Theme::loadSubTemplate('options'); + // Check for variants or dark mode + if (!empty(Theme::$current->settings['theme_variants']) || !empty(Theme::$current->settings['has_dark_mode'])) { + + Lang::load('Themes'); + Utils::$context['additional_options'] = []; + + // Theme Variants + if (!empty(Theme::$current->settings['theme_variants']) && (empty(Theme::$current->settings['disable_user_variant']) || User::$me->allowedTo('admin_forum'))) { + $available_variants = []; + + foreach (Theme::$current->settings['theme_variants'] as $variant) { + $available_variants[$variant] = Lang::getTxt('variant_' . $variant, file: 'Themes') ?? $variant; + } + + Utils::$context['additional_options'][] = Lang::getTxt('theme_opt_variant', file: 'Profile'); + Utils::$context['additional_options'][] = [ + 'id' => 'theme_variant', + 'label' => Lang::getTxt('theme_pick_variant', file: 'THemes'), + 'options' => $available_variants, + 'default' => isset(Theme::$current->settings['default_variant']) && !empty(Theme::$current->settings['default_variant']) ? Theme::$current->settings['default_variant'] : Theme::$current->settings['theme_variants'][0], + 'enabled' => !empty(Theme::$current->settings['theme_variants']), + ]; + } + + // Theme Color Mode + if (!empty(Theme::$current->settings['has_dark_mode']) && (empty(Theme::$current->settings['disable_user_mode']) || User::$me->allowedTo('admin_forum'))) { + $available_modes = []; + + foreach (Theme::$current->settings['theme_colormodes'] as $mode) { + $available_modes[$mode] = Lang::getTxt('colormode_' . $mode, file: 'Themes') ?? $mode; + } + + Utils::$context['additional_options'][] = Lang::getTxt('theme_opt_colormode', file: 'Profile'); + Utils::$context['additional_options'][] = [ + 'id' => 'theme_colormode', + 'label' => Lang::getTxt('theme_pick_colormode', file: 'Themes'), + 'options' => $available_modes, + 'default' => isset(Theme::$current->settings['default_colormode']) && !empty(Theme::$current->settings['default_colormode']) ? Theme::$current->settings['default_colormode'] : Theme::$current->settings['theme_colormodes'][0], + 'enabled' => !empty(Theme::$current->settings['has_dark_mode']), + ]; + } + + Utils::$context['theme_options'] = array_merge(Utils::$context['additional_options'], Utils::$context['theme_options']); + } + // Let mods hook into the theme options. IntegrationHook::call('integrate_theme_options');