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

487 lines 37.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\Framework\Classes\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' => 'notice',
36 'content' => __('<h3>Things Not Working as Expected?</h3>Every theme and page layout is built differently. If a section doesn’t turn dark, it’s usually using a background image, inline style, or custom CSS. Use Darkify’s control settings (color overrides, image filters, exclusions, or custom CSS) to fine-tune the result. If you still need help, <a href="https://wordpress.org/support/plugin/darkify/#new-topic-0" target="_blank">create a support topic</a> anytime—we’re happy to assist.', 'darkify'),
37 ),
38 array(
39 'type' => 'section_tab',
40 'tabs' => array(
41
42 array(
43 'title' => esc_html__('Frontend', 'darkify'),
44 'icon' => 'icofont-computer',
45 'fields' => array(
46 array(
47 'type' => 'heading',
48 'content' => esc_html__('Basic Controls', 'darkify'),
49 ),
50 array(
51 'id' => 'enable_dark_mode_switch',
52 'type' => 'switcher',
53 'title' => esc_html__('Frontend Dark Mode', 'darkify'),
54 'title_help' => '<div class="darkify-info-label">' .
55 __('Show the dark mode floating switch on your website frontend.', 'darkify') .
56 '</div>' . '<a class="tooltip_btn_primary" href="' . esc_url(DARKIFY_DEMO_URL . 'controls/#basic-control-options') . '" target="_blank" rel="noopener noreferrer">' .
57 esc_html__('Live Demo', 'darkify') . '</a>' . '<a class="tooltip_btn_secondary" href="' . esc_url(DARKIFY_DOCS_URL . 'control/#basic-control-options') . '" target="_blank" rel="noopener noreferrer">' .
58 esc_html__('Open Docs', 'darkify') .
59 '</a>',
60 'text_on' => esc_html__('Enabled', 'darkify'),
61 'text_off' => esc_html__('Disabled', 'darkify'),
62 'text_width' => 100,
63 'default' => true,
64 ),
65 array(
66 'id' => 'enable_default_dark_mode',
67 'type' => 'switcher',
68 'title' => esc_html__('Default Dark Mode', 'darkify'),
69 'title_help' =>
70 '<div class="darkify-info-label">' .
71 __('Enable dark mode by default on your website.', 'darkify') .
72 '</div>' .
73 '<a class="tooltip_btn_primary" href="' . esc_url(DARKIFY_DEMO_URL . 'controls/#basic-control-options') . '" target="_blank" rel="noopener noreferrer">' .
74 esc_html__('Live Demo', 'darkify') .
75 '</a>' .
76 '<a class="tooltip_btn_secondary" href="' . esc_url(DARKIFY_DOCS_URL . 'control/#basic-control-options') . '" target="_blank" rel="noopener noreferrer">' .
77 esc_html__('Open Docs', 'darkify') .
78 '</a>',
79 'text_on' => esc_html__('Enabled', 'darkify'),
80 'text_off' => esc_html__('Disabled', 'darkify'),
81 'text_width' => 100,
82 ),
83 array(
84 'id' => 'enable_os_aware',
85 'type' => 'switcher',
86 'title' => esc_html__('OS Aware Dark Mode', 'darkify'),
87 'title_help' =>
88 '<div class="darkify-info-label">' .
89 __('Toggle dark mode based on the user’s device or operating system preference.', 'darkify') .
90 '</div>' .
91 '<a class="tooltip_btn_primary" href="' . esc_url(DARKIFY_DEMO_URL . 'controls/#basic-control-options') . '" target="_blank" rel="noopener noreferrer">' .
92 esc_html__('Live Demo', 'darkify') .
93 '</a>' .
94 '<a class="tooltip_btn_secondary" href="' . esc_url(DARKIFY_DOCS_URL . 'control/#basic-control-options') . '" target="_blank" rel="noopener noreferrer">' .
95 esc_html__('Open Docs', 'darkify') .
96 '</a>',
97 'text_on' => esc_html__('Enabled', 'darkify'),
98 'text_off' => esc_html__('Disabled', 'darkify'),
99 'text_width' => 100,
100 'default' => true,
101 ),
102 array(
103 'id' => 'enable_keyboard_shortcut',
104 'type' => 'switcher',
105 'title' => esc_html__('Keyboard Shortcut', 'darkify'),
106 'title_help' =>
107 '<div class="darkify-info-label">' .
108 __('Toggle dark mode using a keyboard shortcut. Use Ctrl + Alt + D on Windows, and Control + Option + D on macOS.', 'darkify') .
109 '</div>' .
110 '<a class="tooltip_btn_primary" href="' . esc_url(DARKIFY_DEMO_URL . 'controls/#basic-control-options') . '" target="_blank" rel="noopener noreferrer">' .
111 esc_html__('Live Demo', 'darkify') .
112 '</a>' .
113 '<a class="tooltip_btn_secondary" href="' . esc_url(DARKIFY_DOCS_URL . 'control/#basic-control-options') . '" target="_blank" rel="noopener noreferrer">' .
114 esc_html__('Open Docs', 'darkify') .
115 '</a>',
116 'text_on' => esc_html__('Enabled', 'darkify'),
117 'text_off' => esc_html__('Disabled', 'darkify'),
118 'text_width' => 100,
119 'default' => true,
120 ),
121 array(
122 'type' => 'heading',
123 'title' => esc_html__('Advanced Controls', 'darkify'),
124 ),
125 // Enable Time Based Auto Dark Mode
126 array(
127 'id' => 'enable_time',
128 'type' => 'fieldset',
129 'fields' => array(
130 array(
131 'id' => 'enable_time_based_dark',
132 'type' => 'switcher',
133 'title' => esc_html__('Time Based Auto Dark Mode', 'darkify'),
134 'title_help' =>
135 '<div class="darkify-info-label">' .
136 __('Automatically enable dark mode based on the user’s local time.', 'darkify') .
137 '</div>' .
138 '<a class="tooltip_btn_primary" href="' . esc_url(DARKIFY_DEMO_URL . 'controls/#advanced-control-options') . '" target="_blank" rel="noopener noreferrer">' .
139 esc_html__('Live Demo', 'darkify') .
140 '</a>' .
141 '<a class="tooltip_btn_secondary" href="' . esc_url(DARKIFY_DOCS_URL . 'control/#advanced-control-options') . '" target="_blank" rel="noopener noreferrer">' .
142 esc_html__('Open Docs', 'darkify') .
143 '</a>',
144 'text_on' => esc_html__('Enabled', 'darkify'),
145 'text_off' => esc_html__('Disabled', 'darkify'),
146 'text_width' => 100,
147 ),
148 array(
149 'id' => 'enable_time_fields',
150 'type' => 'fieldset',
151 'class' => 'enable_time_fields',
152 'dependency' => array('enable_time_based_dark', '==', 'true'),
153 'title' => esc_html__('Pick a Time', 'darkify'),
154 'title_help' =>
155 '<div class="darkify-info-label">' .
156 __('Set the exact start and end times when dark mode should be automatically enabled or disabled.', 'darkify') .
157 '</div>' .
158 '<a class="tooltip_btn_primary" href="' . esc_url(DARKIFY_DEMO_URL . 'controls/#advanced-control-options') . '" target="_blank" rel="noopener noreferrer">' .
159 esc_html__('Live Demo', 'darkify') .
160 '</a>' .
161 '<a class="tooltip_btn_secondary" href="' . esc_url(DARKIFY_DOCS_URL . 'control/#advanced-control-options') . '" target="_blank" rel="noopener noreferrer">' .
162 esc_html__('Open Docs', 'darkify') .
163 '</a>',
164 'fields' => array(
165 array(
166 'id' => 'time_based_dark_start',
167 'type' => 'datetime',
168 'after' => esc_html__('From', 'darkify'),
169 'placeholder' => esc_html__('From', 'darkify'),
170 'settings' => array(
171 'noCalendar' => true,
172 'enableTime' => true,
173 'dateFormat' => 'H:i',
174 'time_24hr' => false,
175 ),
176 ),
177 array(
178 'id' => 'time_based_dark_end',
179 'type' => 'datetime',
180 'after' => esc_html__('To', 'darkify'),
181 'placeholder' => esc_html__('To', 'darkify'),
182 'settings' => array(
183 'noCalendar' => true,
184 'enableTime' => true,
185 'dateFormat' => 'H:i',
186 'time_24hr' => false,
187 ),
188 ),
189 ),
190 ),
191 ),
192 ),
193 array(
194 'id' => 'hide_on_desktop',
195 'type' => 'switcher',
196 'title' => esc_html__('Hide Dark Mode Switch on Desktop', 'darkify'),
197 'title_help' =>
198 '<div class="darkify-info-label">' .
199 __('Hide the dark mode floating switch when users are browsing on a desktop or laptop.', 'darkify') .
200 '</div>' .
201 '<a class="tooltip_btn_primary" href="' . esc_url(DARKIFY_DEMO_URL . 'controls/#advanced-control-options') . '" target="_blank" rel="noopener noreferrer">' .
202 esc_html__('Live Demo', 'darkify') .
203 '</a>' .
204 '<a class="tooltip_btn_secondary" href="' . esc_url(DARKIFY_DOCS_URL . 'control/#advanced-control-options') . '" target="_blank" rel="noopener noreferrer">' .
205 esc_html__('Open Docs', 'darkify') .
206 '</a>',
207
208 'text_on' => esc_html__('Yes', 'darkify'),
209 'text_off' => esc_html__('No', 'darkify'),
210
211 ),
212 array(
213 'id' => 'hide_on_mobile',
214 'type' => 'fieldset',
215 'fields' => array(
216 array(
217 'id' => 'hide_dark_mode_on_mobile',
218 'type' => 'switcher',
219 'title' => esc_html__('Hide Dark Mode on Mobile', 'darkify'),
220 'title_help' =>
221 '<div class="darkify-info-label">' .
222 __('Hide the dark mode floating switch when users are browsing on mobile devices.', 'darkify') .
223 '</div>' .
224 '<a class="tooltip_btn_primary" href="' . esc_url(DARKIFY_DEMO_URL . 'controls/#advanced-control-options') . '" target="_blank" rel="noopener noreferrer">' .
225 esc_html__('Live Demo', 'darkify') .
226 '</a>' .
227 '<a class="tooltip_btn_secondary" href="' . esc_url(DARKIFY_DOCS_URL . 'control/#advanced-control-options') . '" target="_blank" rel="noopener noreferrer">' .
228 esc_html__('Open Docs', 'darkify') .
229 '</a>',
230
231 'text_on' => esc_html__('Yes', 'darkify'),
232 'text_off' => esc_html__('No', 'darkify'),
233
234 ),
235 array(
236 'id' => 'type_of_hide_by',
237 'type' => 'button_set',
238 'title' => esc_html__('Hide Detection Method', 'darkify'),
239
240 'title_help' =>
241 '<div class="darkify-info-label">' .
242 __('Choose how mobile devices are detected: by User Agent, by Screen Size, or use Both for maximum accuracy.', 'darkify') .
243 '</div>' .
244 '<a class="tooltip_btn_primary" href="' . esc_url(DARKIFY_DEMO_URL . 'controls/#advanced-control-options') . '" target="_blank" rel="noopener noreferrer">' .
245 esc_html__('Live Demo', 'darkify') .
246 '</a>' .
247 '<a class="tooltip_btn_secondary" href="' . esc_url(DARKIFY_DOCS_URL . 'control/#advanced-control-options') . '" target="_blank" rel="noopener noreferrer">' .
248 esc_html__('Open Docs', 'darkify') .
249 '</a>',
250
251 'options' => array(
252 'user_agent' => esc_html__('User Agent', 'darkify'),
253 'screen_size' => esc_html__('Screen Size', 'darkify'),
254 'both' => esc_html__('Both', 'darkify'),
255 ),
256
257 'default' => 'both',
258 'dependency' => array('hide_dark_mode_on_mobile', '==', 'true'),
259 ),
260 ),
261 ),
262 array(
263 'id' => 'show_in_menu',
264 'type' => 'fieldset',
265 'fields' => array(
266 array(
267 'id' => 'enable_switch_in_menu',
268 'type' => 'switcher',
269 'title' => esc_html__('Show Switch in Menu', 'darkify'),
270
271 'title_help' =>
272 '<div class="darkify-info-label">' .
273 __('Show the dark mode toggle switch in a selected menu.', 'darkify') .
274 '</div>' .
275 '<a class="tooltip_btn_primary" href="' . esc_url(DARKIFY_DEMO_URL . 'controls/#advanced-control-options') . '" target="_blank" rel="noopener noreferrer">' .
276 esc_html__('Live Demo', 'darkify') .
277 '</a>' .
278 '<a class="tooltip_btn_secondary" href="' . esc_url(DARKIFY_DOCS_URL . 'control/#menu-integration') . '" target="_blank" rel="noopener noreferrer">' .
279 esc_html__('Open Docs', 'darkify') .
280 '</a>',
281
282 'text_on' => esc_html__('Yes', 'darkify'),
283 'text_off' => esc_html__('No', 'darkify'),
284
285 ),
286 array(
287 'id' => 'select_menus',
288 'type' => 'group',
289 'title' => esc_html__('Menu Switch Settings', 'darkify'),
290
291 'title_help' =>
292 '<div class="darkify-info-label">' .
293 __('Configure menu switch options and placement for your site.', 'darkify') .
294 '</div>' .
295 '<a class="tooltip_btn_primary" href="' . esc_url(DARKIFY_DEMO_URL . 'controls/#advanced-control-options') . '" target="_blank" rel="noopener noreferrer">' .
296 esc_html__('Live Demo', 'darkify') .
297 '</a>' .
298 '<a class="tooltip_btn_secondary" href="' . esc_url(DARKIFY_DOCS_URL . 'control/#menu-integration') . '" target="_blank" rel="noopener noreferrer">' .
299 esc_html__('Open Docs', 'darkify') .
300 '</a>',
301
302 'add_more_text' => sprintf(
303 /* translators: %s: URL to the Darkify Pro pricing page. */
304 __(
305 'Want to use the switch in an unlimited number of menus? <a target="_blank" href="%s"><strong>Upgrade to Pro</strong></a>.',
306 'darkify'
307 ),
308 esc_url(DARKIFY_DEMO_URL . 'pricing/?ref=1')
309 ),
310
311 'accordion_title_number' => true,
312 'accordion_title_auto' => true,
313 'class' => 'select_menus',
314 'max' => 1,
315
316 'fields' => array(
317 array(
318 'id' => 'switch_in_menu_location',
319 'type' => 'select',
320 'class' => 'select_menu_location',
321 'title' => esc_html__('Select Menu', 'darkify'),
322 'title_help' =>
323 '<div class="darkify-info-label">' .
324 esc_html__('Choose a menu from the dropdown list.', 'darkify') .
325 '</div>' .
326 '<a class="tooltip_btn_primary" href="' . esc_url(DARKIFY_DEMO_URL . 'controls/#advanced-control-options') . '" target="_blank" rel="noopener noreferrer">' .
327 esc_html__('Live Demo', 'darkify') .
328 '</a>' .
329 '<a class="tooltip_btn_secondary" href="' . esc_url(DARKIFY_DOCS_URL . 'control/#menu-integration') . '" target="_blank" rel="noopener noreferrer">' .
330 esc_html__('Open Docs', 'darkify') .
331 '</a>',
332 'empty_message' => esc_html__(
333 'You have not created a menu yet. If you are using a Full Site Editing (FSE) theme, copy the shortcode below and paste it where you want the switch to appear.',
334 'darkify'
335 ),
336 'options' => 'menus',
337 ),
338 array(
339 'id' => 'darkify_menu_shortcode_helper',
340 'type' => 'textarea',
341 'title' => esc_html__('Shortcode for Menu', 'darkify'),
342 'title_help' =>
343 '<div class="darkify-info-label">' .
344 __('You can customize the shortcode options based on your preference.', 'darkify') .
345 '</div>' .
346 '<a class="tooltip_btn_primary" href="' . esc_url(DARKIFY_DEMO_URL . 'controls/#advanced-control-options') . '" target="_blank" rel="noopener noreferrer">' .
347 esc_html__('Live Demo', 'darkify') .
348 '</a>' .
349 '<a class="tooltip_btn_secondary" href="' . esc_url(DARKIFY_DOCS_URL . 'control/#menu-integration') . '" target="_blank" rel="noopener noreferrer">' .
350 esc_html__('Open Docs', 'darkify') .
351 '</a>',
352 'default' => '[darkify switch="1" light_mode_bg="#121116" dark_mode_bg="#ffffff" light_mode_color="#ffffff" dark_mode_color="#121116" border="0px" border_light_color="#121119" border_dark_color="#ffffff" border_radius="7px" switch_size="100"]'
353 ),
354 array(
355 'id' => 'select_menu_position',
356 'type' => 'button_set',
357 'title' => esc_html__('Select Menu Position', 'darkify'),
358 'title_help' =>
359 '<div class="darkify-info-label">' .
360 esc_html__('Choose where the dark mode switch should appear in the menu.', 'darkify') .
361 '</div>' .
362 '<a class="tooltip_btn_primary" href="' . esc_url(DARKIFY_DEMO_URL . 'controls/#advanced-control-options') . '" target="_blank" rel="noopener noreferrer">' .
363 esc_html__('Live Demo', 'darkify') .
364 '</a>' .
365 '<a class="tooltip_btn_secondary" href="' . esc_url(DARKIFY_DOCS_URL . 'control/#menu-integration') . '" target="_blank" rel="noopener noreferrer">' .
366 esc_html__('Open Docs', 'darkify') .
367 '</a>',
368
369 'options' => array(
370 'after' => esc_html__('After', 'darkify'),
371 'before' => esc_html__('Before', 'darkify'),
372 ),
373
374 'default' => 'after',
375 ),
376 ),
377 'dependency' => array('enable_switch_in_menu', '==', 'true'),
378 ),
379 ),
380 ),
381 ),
382 ),
383 array(
384 'title' => esc_html__('Admin', 'darkify'),
385 'icon' => 'icofont-dashboard-web',
386 'fields' => array(
387 array(
388 'id' => 'enable_admin_panel_dark_mode',
389 'type' => 'switcher',
390 'title' => esc_html__('Admin Panel Dark Mode', 'darkify'),
391 'title_help' =>
392 '<div class="darkify-info-label">' .
393 __('Enable dark mode in the WordPress admin dashboard.', 'darkify') .
394 '</div>' .
395 '<a class="tooltip_btn_primary" href="' . esc_url(DARKIFY_DEMO_URL . 'controls/#admin') . '" target="_blank" rel="noopener noreferrer">' .
396 esc_html__('Live Demo', 'darkify') .
397 '</a>' .
398 '<a class="tooltip_btn_secondary" href="' . esc_url(DARKIFY_DOCS_URL . 'controls/#admin-controls') . '" target="_blank" rel="noopener noreferrer">' .
399 esc_html__('Open Docs', 'darkify') .
400 '</a>',
401 'text_on' => esc_html__('Enabled', 'darkify'),
402 'text_off' => esc_html__('Disabled', 'darkify'),
403 'default' => false,
404 'text_width' => 100,
405 ),
406
407 array(
408 'id' => 'block_editor_dark_mode',
409 'type' => 'switcher',
410 'title' => esc_html__('Block Editor Dark Mode', 'darkify'),
411 'title_help' =>
412 '<div class="darkify-info-label">' .
413 __('Enable the dark mode switch in the block editor to toggle between dark and light mode.', 'darkify') .
414 '</div>' .
415 '<a class="tooltip_btn_primary" href="' . esc_url(DARKIFY_DEMO_URL . 'controls/#admin') . '" target="_blank" rel="noopener noreferrer">' .
416 esc_html__('Live Demo', 'darkify') .
417 '</a>' .
418 '<a class="tooltip_btn_secondary" href="' . esc_url(DARKIFY_DEMO_URL . 'controls/#admin') . '" target="_blank" rel="noopener noreferrer">' .
419 esc_html__('Open Docs', 'darkify') .
420 '</a>',
421 'text_on' => esc_html__('Enabled', 'darkify'),
422 'text_off' => esc_html__('Disabled', 'darkify'),
423 'default' => true,
424 'text_width' => 100,
425 'dependency' => array('enable_admin_panel_dark_mode', '==', 'true'),
426 ),
427 array(
428 'id' => 'classic_editor_dark_mode',
429 'type' => 'switcher',
430 'title' => esc_html__('Classic Editor Dark Mode', 'darkify'),
431 'title_help' =>
432 '<div class="darkify-info-label">' .
433 __('Enable the dark mode switch in the classic editor to toggle between dark and light modes.', 'darkify') .
434 '</div>' .
435 '<a class="tooltip_btn_primary" href="' . esc_url(DARKIFY_DEMO_URL . 'controls/#admin') . '" target="_blank" rel="noopener noreferrer">' .
436 esc_html__('Live Demo', 'darkify') .
437 '</a>' .
438 '<a class="tooltip_btn_secondary" href="' . esc_url(DARKIFY_DEMO_URL . 'controls/#admin') . '" target="_blank" rel="noopener noreferrer">' .
439 esc_html__('Open Docs', 'darkify') .
440 '</a>',
441 'text_on' => esc_html__('Enabled', 'darkify'),
442 'text_off' => esc_html__('Disabled', 'darkify'),
443
444 'default' => true,
445 'text_width' => 100,
446 ),
447
448 array(
449 'id' => 'disallowed_admin_pages',
450 'type' => 'textarea',
451 'title' => esc_html__('Disallowed Pages', 'darkify'),
452 'title_help' => '<div class="darkify-info-text">' .
453 __('If an admin page URL looks like http://example.com/wp-admin/admin.php?page=darkify, then "darkify" is the page slug.', 'darkify') .
454 '</div>' .
455 '<a class="tooltip_btn_primary" href="' . esc_url(DARKIFY_DEMO_URL . 'controls/#admin') . '" target="_blank" rel="noopener noreferrer">' .
456 esc_html__('Live Demo', 'darkify') .
457 '</a>' .
458 '<a class="tooltip_btn_secondary" href="' . esc_url(DARKIFY_DOCS_URL . 'controls/#admin-controls') . '" target="_blank" rel="noopener noreferrer">' .
459 esc_html__('Open Docs', 'darkify') .
460 '</a>',
461 'placeholder' => esc_html__('Enter comma-separated page slugs. Example: darkify-dashboard, elementor', 'darkify'),
462 'dependency' => array('enable_admin_panel_dark_mode', '==', 'true'),
463 'class' => 'only_pro'
464 ),
465 array(
466 'id' => 'admin_custom_css',
467 'type' => 'code_editor',
468 'title' => esc_html__('Admin Dark Mode CSS', 'darkify'),
469 'title_help' =>
470 '<div class="darkify-info-label">' .
471 __('The CSS code will only be applied when admin dark mode is active.', 'darkify') .
472 '</div>',
473 'settings' => array(
474 'theme' => 'mbo',
475 'mode' => 'css',
476 ),
477 ),
478 ),
479 ),
480 ),
481 ),
482 ),
483 ),
484 );
485 }
486 }
487