PluginProbe
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) / 2.0.1
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) v2.0.1
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.1, at src/Admin/Views/Control.php

341 lines 22.2 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 /*
177 * Which clock drives the schedule. Darkify Lite ships
178 * only "fixed" (the start/end window below); the
179 * sunrise/sunset schedule is a Pro feature, so its
180 * option row carries `pro_only` — the REST layer turns
181 * that into the `pro_options` stamp the React admin
182 * renders as a locked, badged preview, and
183 * strip_pro_keys() refuses to persist the value even
184 * if a crafted request sends it.
185 */
186 array(
187 'id' => 'time_based_dark_mode',
188 'type' => 'button_set',
189 'default' => 'fixed',
190 'options' => array(
191 'fixed' => esc_html__('Fixed times', 'darkify'),
192 'suncycle' => array(
193 'text' => esc_html__('Sunrise & sunset', 'darkify'),
194 'pro_only' => true,
195 ),
196 ),
197 ),
198 array(
199 'id' => 'time_based_dark_start',
200 'type' => 'datetime',
201 'after' => esc_html__('From', 'darkify'),
202 'placeholder' => esc_html__('From', 'darkify'),
203 'settings' => array(
204 'noCalendar' => true,
205 'enableTime' => true,
206 'dateFormat' => 'H:i',
207 'time_24hr' => false,
208 ),
209 ),
210 array(
211 'id' => 'time_based_dark_end',
212 'type' => 'datetime',
213 'after' => esc_html__('To', 'darkify'),
214 'placeholder' => esc_html__('To', 'darkify'),
215 'settings' => array(
216 'noCalendar' => true,
217 'enableTime' => true,
218 'dateFormat' => 'H:i',
219 'time_24hr' => false,
220 ),
221 ),
222 ),
223 ),
224 ),
225 ),
226 ),
227 ),
228 array(
229 'title' => esc_html__('Admin', 'darkify'),
230 'icon' => 'icofont-dashboard-web',
231 'fields' => array(
232 // Intro line with a docs link, rendered plain above the section cards.
233 array(
234 'type' => 'page_hint',
235 'content' => sprintf(
236 /* translators: %s: documentation link */
237 __('Bring dark mode to the WordPress admin dashboard and editors. %s', 'darkify'),
238 '<a href="https://darkifywp.com/docs/" target="_blank" rel="noopener noreferrer">' . esc_html__('View documentation', 'darkify') . '</a>'
239 ),
240 ),
241 // ===== ADMIN APPEARANCE =====
242 array(
243 'type' => 'heading',
244 'title' => esc_html__('Admin Appearance', 'darkify'),
245 'section_start' => true,
246 ),
247 array(
248 'id' => 'enable_admin_panel_dark_mode',
249 'type' => 'switcher',
250 'title' => esc_html__('Admin Panel Dark Mode', 'darkify'),
251 'title_help' =>
252 '<div class="darkify-info-label">' .
253 __('Enable dark mode in the WordPress admin dashboard.', 'darkify') .
254 '</div>' .
255 '' .
256 '',
257 'text_on' => esc_html__('Enabled', 'darkify'),
258 'text_off' => esc_html__('Disabled', 'darkify'),
259 'default' => false,
260 'text_width' => 100,
261 // Commit instantly even though other fields depend on it.
262 'auto_save' => true,
263 ),
264
265 array(
266 'id' => 'block_editor_dark_mode',
267 'type' => 'switcher',
268 'title' => esc_html__('Block Editor Dark Mode', 'darkify'),
269 'title_help' =>
270 '<div class="darkify-info-label">' .
271 __('Enable the dark mode switch in the block editor to toggle between dark and light mode.', 'darkify') .
272 '</div>' .
273 '' .
274 '',
275 'text_on' => esc_html__('Enabled', 'darkify'),
276 'text_off' => esc_html__('Disabled', 'darkify'),
277 'default' => false,
278 'text_width' => 100,
279 ),
280 array(
281 'id' => 'classic_editor_dark_mode',
282 'type' => 'switcher',
283 'title' => esc_html__('Classic Editor Dark Mode', 'darkify'),
284 'title_help' =>
285 '<div class="darkify-info-label">' .
286 __('Enable the dark mode switch in the classic editor to toggle between dark and light modes.', 'darkify') .
287 '</div>' .
288 '' .
289 '',
290 'text_on' => esc_html__('Enabled', 'darkify'),
291 'text_off' => esc_html__('Disabled', 'darkify'),
292
293 'default' => false,
294 'text_width' => 100,
295 ),
296
297 // ===== SCOPE & CUSTOMIZATION =====
298 array(
299 'type' => 'heading',
300 'title' => esc_html__('Scope & Customization', 'darkify'),
301 'section_start' => true,
302 'dependency' => array('enable_admin_panel_dark_mode', '==', 'true'),
303 ),
304 array(
305 'id' => 'disallowed_admin_pages',
306 'type' => 'textarea',
307 'title' => esc_html__('Disallowed Pages', 'darkify'),
308 'title_help' => '<div class="darkify-info-text">' .
309 __('If an admin page URL looks like http://example.com/wp-admin/admin.php?page=darkify, then "darkify" is the page slug.', 'darkify') .
310 '</div>' .
311 '' .
312 '',
313 'placeholder' => esc_html__('Enter comma-separated page slugs. Example: darkify-dashboard, elementor', 'darkify'),
314 'dependency' => array('enable_admin_panel_dark_mode', '==', 'true'),
315 'class' => 'only_pro'
316 ),
317 array(
318 'id' => 'admin_custom_css',
319 'type' => 'code_editor',
320 'title' => esc_html__('Admin Dark Mode CSS', 'darkify'),
321 'title_help' =>
322 '<div class="darkify-info-label">' .
323 __('The CSS code will only be applied when admin dark mode is active.', 'darkify') .
324 '</div>',
325 'settings' => array(
326 'theme' => 'mbo',
327 'mode' => 'css',
328 ),
329 // Only relevant when admin dark mode is active — hide it while off.
330 'dependency' => array('enable_admin_panel_dark_mode', '==', 'true'),
331 ),
332 ),
333 ),
334 ),
335 ),
336 ),
337 ),
338 );
339 }
340 }
341