@@ -43,6 +43,51 @@ public function execute(): void
4343 Theme::loadTemplate ('Settings ' );
4444 Theme::loadSubTemplate ('options ' );
4545
46+ // Check for variants or dark mode
47+ if (!empty (Theme::$ current ->settings ['theme_variants ' ]) || !empty (Theme::$ current ->settings ['has_dark_mode ' ])) {
48+
49+ Lang::load ('Themes ' );
50+ Utils::$ context ['additional_options ' ] = [];
51+
52+ // Theme Variants
53+ if (!empty (Theme::$ current ->settings ['theme_variants ' ]) && (empty (Theme::$ current ->settings ['disable_user_variant ' ]) || User::$ me ->allowedTo ('admin_forum ' ))) {
54+ $ available_variants = [];
55+
56+ foreach (Theme::$ current ->settings ['theme_variants ' ] as $ variant ) {
57+ $ available_variants [$ variant ] = Lang::getTxt ('variant_ ' . $ variant , file: 'Themes ' ) ?? $ variant ;
58+ }
59+
60+ Utils::$ context ['additional_options ' ][] = Lang::getTxt ('theme_opt_variant ' , file: 'Profile ' );
61+ Utils::$ context ['additional_options ' ][] = [
62+ 'id ' => 'theme_variant ' ,
63+ 'label ' => Lang::getTxt ('theme_pick_variant ' , file: 'THemes ' ),
64+ 'options ' => $ available_variants ,
65+ 'default ' => isset (Theme::$ current ->settings ['default_variant ' ]) && !empty (Theme::$ current ->settings ['default_variant ' ]) ? Theme::$ current ->settings ['default_variant ' ] : Theme::$ current ->settings ['theme_variants ' ][0 ],
66+ 'enabled ' => !empty (Theme::$ current ->settings ['theme_variants ' ]),
67+ ];
68+ }
69+
70+ // Theme Color Mode
71+ if (!empty (Theme::$ current ->settings ['has_dark_mode ' ]) && (empty (Theme::$ current ->settings ['disable_user_mode ' ]) || User::$ me ->allowedTo ('admin_forum ' ))) {
72+ $ available_modes = [];
73+
74+ foreach (Theme::$ current ->settings ['theme_colormodes ' ] as $ mode ) {
75+ $ available_modes [$ mode ] = Lang::getTxt ('colormode_ ' . $ mode , file: 'Themes ' ) ?? $ mode ;
76+ }
77+
78+ Utils::$ context ['additional_options ' ][] = Lang::getTxt ('theme_opt_colormode ' , file: 'Profile ' );
79+ Utils::$ context ['additional_options ' ][] = [
80+ 'id ' => 'theme_colormode ' ,
81+ 'label ' => Lang::getTxt ('theme_pick_colormode ' , file: 'Themes ' ),
82+ 'options ' => $ available_modes ,
83+ 'default ' => isset (Theme::$ current ->settings ['default_colormode ' ]) && !empty (Theme::$ current ->settings ['default_colormode ' ]) ? Theme::$ current ->settings ['default_colormode ' ] : Theme::$ current ->settings ['theme_colormodes ' ][0 ],
84+ 'enabled ' => !empty (Theme::$ current ->settings ['has_dark_mode ' ]),
85+ ];
86+ }
87+
88+ Utils::$ context ['theme_options ' ] = array_merge (Utils::$ context ['additional_options ' ], Utils::$ context ['theme_options ' ]);
89+ }
90+
4691 // Let mods hook into the theme options.
4792 IntegrationHook::call ('integrate_theme_options ' );
4893
0 commit comments