PluginProbe
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) / 2.0.0
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) v2.0.0
2.1.3 2.1.2 2.1.1 2.1.0 2.0.4 2.0.3 2.0.2 2.0.1 2.0.0 1.5.5 1.5.4 1.5.3 1.5.2 1.5.1 1.5.0 trunk 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 All 57 releases
darkify / src / Admin / Views / Control.php

Control.php in Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) 2.0.0, at src/Admin/Views/Control.php

319 lines 20.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Control class for Control options.
5 *
6 * @link https://themeatelier.net
7 * @since 1.0.0
8 *
9 * @package darkify
10 * @subpackage darkify/src/Admin/Views/Control
11 * @author ThemeAtelier<themeatelierbd@gmail.com>
12 */
13
14 namespace ThemeAtelier\Darkify\Admin\Views;
15
16 use ThemeAtelier\Darkify\Admin\Schema\SchemaRegistry as Darkify;
17
18 class Control
19 {
20 /**
21 * Create Option fields for the setting options.
22 *
23 * @param string $prefix Option setting key prefix.
24 * @return void
25 */
26 public static function options($prefix)
27 {
28 Darkify::createSection(
29 $prefix,
30 array(
31 'title' => esc_html__('Controls', 'darkify'),
32 'icon' => 'icofont-ui-settings',
33 'fields' => array(
34 array(
35 'type' => 'section_tab',
36 'tabs' => array(
37
38 array(
39 'title' => esc_html__('Frontend', 'darkify'),
40 'icon' => 'icofont-computer',
41 'fields' => array(
42 // Intro line with a docs link, rendered plain above the section cards.
43 array(
44 'type' => 'page_hint',
45 'content' => sprintf(
46 /* translators: %s: documentation link */
47 __('Decide how and when dark mode turns on for visitors on your public website. %s', 'darkify'),
48 '<a href="https://darkifywp.com/docs/" target="_blank" rel="noopener noreferrer">' . esc_html__('View documentation', 'darkify') . '</a>'
49 ),
50 ),
51
52 // ===== AVAILABILITY =====
53 array(
54 'type' => 'heading',
55 'title' => esc_html__('Availability', 'darkify'),
56 'section_start' => true,
57 ),
58 array(
59 'id' => 'enable_dark_mode_switch',
60 'type' => 'switcher',
61 'title' => esc_html__('Frontend Dark Mode', 'darkify'),
62 'title_help' => '<div class="darkify-info-label">' .
63 __('Show the dark mode floating switch on your website frontend. This is the master control for everything below.', 'darkify') .
64 '</div>' . '' . '',
65 'text_on' => esc_html__('Enabled', 'darkify'),
66 'text_off' => esc_html__('Disabled', 'darkify'),
67 'text_width' => 100,
68 'default' => true,
69 // Commit instantly (master toggle governs the whole frontend feature).
70 'auto_save' => true,
71 ),
72 array(
73 'id' => 'enable_default_dark_mode',
74 'type' => 'switcher',
75 'title' => esc_html__('Default Dark Mode', 'darkify'),
76 'title_help' =>
77 '<div class="darkify-info-label">' .
78 __('Enable dark mode by default on your website.', 'darkify') .
79 '</div>' .
80 '' .
81 '',
82 'text_on' => esc_html__('Enabled', 'darkify'),
83 'text_off' => esc_html__('Disabled', 'darkify'),
84 'text_width' => 100,
85 // Commit instantly (the priority notice depends on it, which would
86 // otherwise force the manual-Save workflow).
87 'auto_save' => true,
88 ),
89 array(
90 'id' => 'enable_os_aware',
91 'type' => 'switcher',
92 'title' => esc_html__('OS Aware Dark Mode', 'darkify'),
93 'title_help' =>
94 '<div class="darkify-info-label">' .
95 __('Toggle dark mode based on the user’s device or operating system preference.', 'darkify') .
96 '</div>' .
97 '' .
98 '',
99 'text_on' => esc_html__('Enabled', 'darkify'),
100 'text_off' => esc_html__('Disabled', 'darkify'),
101 'text_width' => 100,
102 'default' => true,
103 // Commit instantly (the priority notice depends on it).
104 'auto_save' => true,
105 ),
106 // Priority notice: shown only when Default Dark Mode AND OS Aware are both on.
107 array(
108 'type' => 'submessage',
109 'style' => 'info',
110 'content' => '<strong>' . esc_html__('OS Aware takes priority.', 'darkify') . '</strong> ' . esc_html__('Both are on, so visitors following the system “dark” setting get dark mode automatically; Default Dark Mode applies only when no system preference is detected.', 'darkify'),
111 'dependency' => array('enable_default_dark_mode|enable_os_aware', '==|==', 'true|true'),
112 ),
113
114 // ===== ACTIVATION =====
115 array(
116 'type' => 'heading',
117 'title' => esc_html__('Activation', 'darkify'),
118 'section_start' => true,
119 ),
120 array(
121 'id' => 'enable_keyboard_shortcut',
122 'type' => 'switcher',
123 'title' => esc_html__('Keyboard Shortcut', 'darkify'),
124 'title_help' =>
125 '<div class="darkify-info-label">' .
126 __('Let visitors toggle dark mode with a keyboard shortcut.', 'darkify') .
127 '</div>' .
128 '' .
129 '',
130 'text_on' => esc_html__('Enabled', 'darkify'),
131 'text_off' => esc_html__('Disabled', 'darkify'),
132 'text_width' => 100,
133 'default' => true,
134 // Commit instantly (the shortcut-keys field depends on it).
135 'auto_save' => true,
136 ),
137 // Editable shortcut combo (shown when the shortcut is enabled).
138 array(
139 'id' => 'keyboard_shortcut_keys',
140 'type' => 'keyboard_shortcut',
141 'default' => 'ctrl+alt+d',
142 'dependency' => array('enable_keyboard_shortcut', '==', 'true'),
143 ),
144 // Enable Time Based Auto Dark Mode
145 array(
146 'id' => 'enable_time',
147 'type' => 'fieldset',
148 'fields' => array(
149 array(
150 'id' => 'enable_time_based_dark',
151 'type' => 'switcher',
152 'title' => esc_html__('Time Based Auto Dark Mode', 'darkify'),
153 'title_help' =>
154 '<div class="darkify-info-label">' .
155 __('Automatically enable dark mode based on the user’s local time.', 'darkify') .
156 '</div>' .
157 '' .
158 '',
159 'text_on' => esc_html__('Enabled', 'darkify'),
160 'text_off' => esc_html__('Disabled', 'darkify'),
161 'text_width' => 100,
162 ),
163 array(
164 'id' => 'enable_time_fields',
165 'type' => 'fieldset',
166 'class' => 'enable_time_fields',
167 'dependency' => array('enable_time_based_dark', '==', 'true'),
168 'title' => esc_html__('Pick a Time', 'darkify'),
169 'title_help' =>
170 '<div class="darkify-info-label">' .
171 __('Set the exact start and end times when dark mode should be automatically enabled or disabled.', 'darkify') .
172 '</div>' .
173 '' .
174 '',
175 'fields' => array(
176 array(
177 'id' => 'time_based_dark_start',
178 'type' => 'datetime',
179 'after' => esc_html__('From', 'darkify'),
180 'placeholder' => esc_html__('From', 'darkify'),
181 'settings' => array(
182 'noCalendar' => true,
183 'enableTime' => true,
184 'dateFormat' => 'H:i',
185 'time_24hr' => false,
186 ),
187 ),
188 array(
189 'id' => 'time_based_dark_end',
190 'type' => 'datetime',
191 'after' => esc_html__('To', 'darkify'),
192 'placeholder' => esc_html__('To', 'darkify'),
193 'settings' => array(
194 'noCalendar' => true,
195 'enableTime' => true,
196 'dateFormat' => 'H:i',
197 'time_24hr' => false,
198 ),
199 ),
200 ),
201 ),
202 ),
203 ),
204 ),
205 ),
206 array(
207 'title' => esc_html__('Admin', 'darkify'),
208 'icon' => 'icofont-dashboard-web',
209 'fields' => array(
210 // Intro line with a docs link, rendered plain above the section cards.
211 array(
212 'type' => 'page_hint',
213 'content' => sprintf(
214 /* translators: %s: documentation link */
215 __('Bring dark mode to the WordPress admin dashboard and editors. %s', 'darkify'),
216 '<a href="https://darkifywp.com/docs/" target="_blank" rel="noopener noreferrer">' . esc_html__('View documentation', 'darkify') . '</a>'
217 ),
218 ),
219 // ===== ADMIN APPEARANCE =====
220 array(
221 'type' => 'heading',
222 'title' => esc_html__('Admin Appearance', 'darkify'),
223 'section_start' => true,
224 ),
225 array(
226 'id' => 'enable_admin_panel_dark_mode',
227 'type' => 'switcher',
228 'title' => esc_html__('Admin Panel Dark Mode', 'darkify'),
229 'title_help' =>
230 '<div class="darkify-info-label">' .
231 __('Enable dark mode in the WordPress admin dashboard.', 'darkify') .
232 '</div>' .
233 '' .
234 '',
235 'text_on' => esc_html__('Enabled', 'darkify'),
236 'text_off' => esc_html__('Disabled', 'darkify'),
237 'default' => false,
238 'text_width' => 100,
239 // Commit instantly even though other fields depend on it.
240 'auto_save' => true,
241 ),
242
243 array(
244 'id' => 'block_editor_dark_mode',
245 'type' => 'switcher',
246 'title' => esc_html__('Block Editor Dark Mode', 'darkify'),
247 'title_help' =>
248 '<div class="darkify-info-label">' .
249 __('Enable the dark mode switch in the block editor to toggle between dark and light mode.', 'darkify') .
250 '</div>' .
251 '' .
252 '',
253 'text_on' => esc_html__('Enabled', 'darkify'),
254 'text_off' => esc_html__('Disabled', 'darkify'),
255 'default' => false,
256 'text_width' => 100,
257 ),
258 array(
259 'id' => 'classic_editor_dark_mode',
260 'type' => 'switcher',
261 'title' => esc_html__('Classic Editor Dark Mode', 'darkify'),
262 'title_help' =>
263 '<div class="darkify-info-label">' .
264 __('Enable the dark mode switch in the classic editor to toggle between dark and light modes.', 'darkify') .
265 '</div>' .
266 '' .
267 '',
268 'text_on' => esc_html__('Enabled', 'darkify'),
269 'text_off' => esc_html__('Disabled', 'darkify'),
270
271 'default' => false,
272 'text_width' => 100,
273 ),
274
275 // ===== SCOPE & CUSTOMIZATION =====
276 array(
277 'type' => 'heading',
278 'title' => esc_html__('Scope & Customization', 'darkify'),
279 'section_start' => true,
280 'dependency' => array('enable_admin_panel_dark_mode', '==', 'true'),
281 ),
282 array(
283 'id' => 'disallowed_admin_pages',
284 'type' => 'textarea',
285 'title' => esc_html__('Disallowed Pages', 'darkify'),
286 'title_help' => '<div class="darkify-info-text">' .
287 __('If an admin page URL looks like http://example.com/wp-admin/admin.php?page=darkify, then "darkify" is the page slug.', 'darkify') .
288 '</div>' .
289 '' .
290 '',
291 'placeholder' => esc_html__('Enter comma-separated page slugs. Example: darkify-dashboard, elementor', 'darkify'),
292 'dependency' => array('enable_admin_panel_dark_mode', '==', 'true'),
293 'class' => 'only_pro'
294 ),
295 array(
296 'id' => 'admin_custom_css',
297 'type' => 'code_editor',
298 'title' => esc_html__('Admin Dark Mode CSS', 'darkify'),
299 'title_help' =>
300 '<div class="darkify-info-label">' .
301 __('The CSS code will only be applied when admin dark mode is active.', 'darkify') .
302 '</div>',
303 'settings' => array(
304 'theme' => 'mbo',
305 'mode' => 'css',
306 ),
307 // Only relevant when admin dark mode is active — hide it while off.
308 'dependency' => array('enable_admin_panel_dark_mode', '==', 'true'),
309 ),
310 ),
311 ),
312 ),
313 ),
314 ),
315 ),
316 );
317 }
318 }
319