PluginProbe
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) / 1.4.6
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) v1.4.6
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
← All changes | src/Admin/Views/Control.php +131 -228 2.0.41.4.6 View file →
@@ -1,8 +1,8 @@
1 1 <?php
2 2
3 3 /**
4 - * Control class for Control options.
4 + * Views class for Shortcode generator options.
5 5 *
6 6 * @link https://themeatelier.net
7 7 * @since 1.0.0
8 8 *
@@ -12,9 +12,9 @@
12 12 */
13 13
14 14 namespace ThemeAtelier\Darkify\Admin\Views;
15 15
16 -use ThemeAtelier\Darkify\Admin\Schema\SchemaRegistry as Darkify;
16 +use ThemeAtelier\Darkify\Admin\Framework\Classes\Darkify;
17 17
18 18 class Control
19 19 {
20 20 /**
@@ -27,15 +27,9 @@
27 27 {
28 28 Darkify::createSection(
29 29 $prefix,
30 30 array(
31 - // Explicit, locale-independent id. Without it the REST layer falls
32 - // back to sanitize_title() of the *translated* title, so the route
33 - // became #/sterowanie on a Polish site and every link 404'd inside
34 - // the SPA. Value matches the old English slug so existing
35 - // `#tab=` / `#/controls` bookmarks keep resolving.
36 - 'id' => 'controls',
37 - 'title' => esc_html__('Controls', 'darkify'),
31 + 'title' => esc_html__('CONTROLS', 'darkify'),
38 32 'icon' => 'icofont-ui-settings',
39 33 'fields' => array(
40 34 array(
41 35 'type' => 'section_tab',
@@ -41,113 +35,66 @@
41 35 'type' => 'section_tab',
42 36 'tabs' => array(
43 37
44 38 array(
45 - 'id' => 'frontend',
46 39 'title' => esc_html__('Frontend', 'darkify'),
47 40 'icon' => 'icofont-computer',
48 41 'fields' => array(
49 - // Intro line with a docs link, rendered plain above the section cards.
50 42 array(
51 - 'type' => 'page_hint',
52 - 'content' => sprintf(
53 - /* translators: %s: documentation link */
54 - __('Decide how and when dark mode turns on for visitors on your public website. %s', 'darkify'),
55 - '<a href="https://darkifywp.com/docs/" target="_blank" rel="noopener noreferrer">' . esc_html__('View documentation', 'darkify') . '</a>'
56 - ),
43 + 'type' => 'heading',
44 + 'content' => esc_html__('Basic Control', 'darkify'),
57 45 ),
58 -
59 - // ===== AVAILABILITY =====
60 46 array(
61 - 'type' => 'heading',
62 - 'title' => esc_html__('Availability', 'darkify'),
63 - 'section_start' => true,
64 - ),
65 - array(
66 47 'id' => 'enable_dark_mode_switch',
67 48 'type' => 'switcher',
68 - 'title' => esc_html__('Frontend Dark Mode', 'darkify'),
69 - 'title_help' => '<div class="darkify-info-label">' .
70 - __('Show the dark mode floating switch on your website frontend. This is the master control for everything below.', 'darkify') .
71 - '</div>' . '' . '',
49 + 'title' => esc_html__('Frontend Dark Mode', 'darkify'),
50 + 'title_help' => '<div class="darkify-info-label">' . __('Show the dark mode floating switch in your Website\'s frontend.', 'darkify') . '</div><a class="tooltip_btn_primary" href="https://darkifywp.com/controls/" target="_blank">' . __('Live Demo', 'darkify') . '</a><a class="tooltip_btn_secondary" href="https://docs.themeatelier.net/docs/darkify-pro/darkify-settings/control/" target="_blank">' . __('Open Docs', 'darkify') . '</a>',
72 51 'text_on' => esc_html__('Enabled', 'darkify'),
73 52 'text_off' => esc_html__('Disabled', 'darkify'),
74 53 'text_width' => 100,
75 54 'default' => true,
76 - // Commit instantly (master toggle governs the whole frontend feature).
77 - 'auto_save' => true,
78 55 ),
79 56 array(
80 57 'id' => 'enable_default_dark_mode',
81 58 'type' => 'switcher',
82 - 'title' => esc_html__('Default Dark Mode', 'darkify'),
83 - 'title_help' =>
84 - '<div class="darkify-info-label">' .
85 - __('Enable dark mode by default on your website.', 'darkify') .
86 - '</div>' .
87 - '' .
88 - '',
89 - 'text_on' => esc_html__('Enabled', 'darkify'),
90 - 'text_off' => esc_html__('Disabled', 'darkify'),
59 + 'title' => esc_html__('Default Dark Mode', 'darkify'),
60 + 'title_help' => '<div class="darkify-info-label">' . __('Automatically turn your website dark by default.', 'darkify') . '</div>',
61 + 'text_on' => esc_html__('Enabled', 'darkify'),
62 + 'text_off' => esc_html__('Disabled', 'darkify'),
91 63 'text_width' => 100,
92 - // Commit instantly (the priority notice depends on it, which would
93 - // otherwise force the manual-Save workflow).
94 - 'auto_save' => true,
64 + // 'title_video' => '<div class="darkify-img-tag">
65 + // <video autoplay loop muted playsinline>
66 + // <source src="https://plugins.svn.wordpress.org/darkify/assets/video/os-aware-darkmode.webm" type="video/webm">
67 + // </video>
68 + // </div><div class="darkify-info-label">Auto Convert Dropdowns to Button</div>',
95 69 ),
96 70 array(
97 71 'id' => 'enable_os_aware',
98 72 'type' => 'switcher',
99 - 'title' => esc_html__('OS Aware Dark Mode', 'darkify'),
100 - 'title_help' =>
101 - '<div class="darkify-info-label">' .
102 - __('Toggle dark mode based on the user’s device or operating system preference.', 'darkify') .
103 - '</div>' .
104 - '' .
105 - '',
106 - 'text_on' => esc_html__('Enabled', 'darkify'),
107 - 'text_off' => esc_html__('Disabled', 'darkify'),
73 + 'title' => esc_html__('OS Aware Dark Mode', 'darkify'),
74 + 'title_video' => '<div class="darkify-img-tag">
75 + <video autoplay loop muted playsinline>
76 + <source src="https://plugins.svn.wordpress.org/darkify/assets/videos/os-aware-darkmode.webm" type="video/webm">
77 + </video>
78 + </div><div class="darkify-info-label">Dark Mode toggling based on OS setting</div>',
79 + 'text_on' => esc_html__('Enabled', 'darkify'),
80 + 'text_off' => esc_html__('Disabled', 'darkify'),
108 81 'text_width' => 100,
109 82 'default' => true,
110 - // Commit instantly (the priority notice depends on it).
111 - 'auto_save' => true,
112 83 ),
113 - // Priority notice: shown only when Default Dark Mode AND OS Aware are both on.
114 84 array(
115 - 'type' => 'submessage',
116 - 'style' => 'info',
117 - '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'),
118 - 'dependency' => array('enable_default_dark_mode|enable_os_aware', '==|==', 'true|true'),
119 - ),
120 -
121 - // ===== ACTIVATION =====
122 - array(
123 - 'type' => 'heading',
124 - 'title' => esc_html__('Activation', 'darkify'),
125 - 'section_start' => true,
126 - ),
127 - array(
128 85 'id' => 'enable_keyboard_shortcut',
129 86 'type' => 'switcher',
130 - 'title' => esc_html__('Keyboard Shortcut', 'darkify'),
131 - 'title_help' =>
132 - '<div class="darkify-info-label">' .
133 - __('Let visitors toggle dark mode with a keyboard shortcut.', 'darkify') .
134 - '</div>' .
135 - '' .
136 - '',
137 - 'text_on' => esc_html__('Enabled', 'darkify'),
138 - 'text_off' => esc_html__('Disabled', 'darkify'),
87 + 'title' => esc_html__('Keyboard Shortcut', 'darkify'),
88 + 'title_help' => '<div class="darkify-info-label">' . __('Enable to dark mode by pressing Ctrl+Alt+D on windows keyboard & Ctrl+Opt|Start+D on mac.', 'darkify') . '</div>',
89 + 'text_on' => esc_html__('Enabled', 'darkify'),
90 + 'text_off' => esc_html__('Disabled', 'darkify'),
139 91 'text_width' => 100,
140 92 'default' => true,
141 - // Commit instantly (the shortcut-keys field depends on it).
142 - 'auto_save' => true,
143 93 ),
144 - // Editable shortcut combo (shown when the shortcut is enabled).
145 94 array(
146 - 'id' => 'keyboard_shortcut_keys',
147 - 'type' => 'keyboard_shortcut',
148 - 'default' => 'ctrl+alt+d',
149 - 'dependency' => array('enable_keyboard_shortcut', '==', 'true'),
95 + 'type' => 'heading',
96 + 'title' => esc_html__('Advanced Control', 'darkify'),
150 97 ),
151 98 // Enable Time Based Auto Dark Mode
152 99 array(
153 100 'id' => 'enable_time',
@@ -156,78 +103,113 @@
156 103 array(
157 104 'id' => 'enable_time_based_dark',
158 105 'type' => 'switcher',
159 106 'title' => esc_html__('Time Based Auto Dark Mode', 'darkify'),
160 - 'title_help' =>
161 - '<div class="darkify-info-label">' .
162 - __('Automatically enable dark mode based on the user’s local time.', 'darkify') .
163 - '</div>' .
164 - '' .
165 - '',
166 - 'text_on' => esc_html__('Enabled', 'darkify'),
167 - 'text_off' => esc_html__('Disabled', 'darkify'),
107 + 'title_help' => '<div class="darkify-info-label">' . __('Automatically turn dark mode ON based on users’ localtime.', 'darkify') . '</div>',
108 + 'text_on' => esc_html__('Enabled', 'darkify'),
109 + 'text_off' => esc_html__('Disabled', 'darkify'),
168 110 'text_width' => 100,
169 111 ),
170 112 array(
171 - 'id' => 'enable_time_fields',
172 - 'type' => 'fieldset',
173 - 'class' => 'enable_time_fields',
113 + 'id' => 'time_based_dark_start',
114 + 'type' => 'datetime',
115 + 'title' => esc_html__('Pick a Time', 'darkify'),
116 + 'from_to' => true,
117 + 'text_from' => esc_html__('Form', 'darkify'),
118 + 'text_to' => esc_html__('To', 'darkify'),
119 + 'settings' => array(
120 + 'noCalendar' => true,
121 + 'enableTime' => true,
122 + 'dateFormat' => 'H:i',
123 + 'time_24hr' => false,
124 + ),
174 125 'dependency' => array('enable_time_based_dark', '==', 'true'),
175 - 'title' => esc_html__('Pick a Time', 'darkify'),
176 - 'title_help' =>
177 - '<div class="darkify-info-label">' .
178 - __('Set the exact start and end times when dark mode should be automatically enabled or disabled.', 'darkify') .
179 - '</div>' .
180 - '' .
181 - '',
126 + ),
127 + ),
128 + ),
129 + array(
130 + 'id' => 'hide_on_desktop',
131 + 'type' => 'switcher',
132 + 'title' => esc_html__('Hide Dark Mode Switch On Desktop', 'darkify'),
133 + 'title_help' => '<div class="darkify-info-label">' . __('Hide the Dark Mode Floating Switch if users’ are using desktop or laptop.', 'darkify') . '</div>',
134 + 'text_on' => esc_html__('Yes', 'darkify'),
135 + 'text_off' => esc_html__('No', 'darkify'),
136 + ),
137 + array(
138 + 'id' => 'hide_on_mobile',
139 + 'type' => 'fieldset',
140 + 'fields' => array(
141 + array(
142 + 'id' => 'hide_dark_mode_on_mobile',
143 + 'type' => 'switcher',
144 + 'title' => esc_html__('Hide Dark Mode On Mobile', 'darkify'),
145 + 'title_help' => '<div class="darkify-info-label">' . __('Hide the Dark Mode Floating Switch if users’ are using mobile.', 'darkify') . '</div>',
146 + 'text_on' => esc_html__('Yes', 'darkify'),
147 + 'text_off' => esc_html__('No', 'darkify'),
148 + ),
149 + array(
150 + 'id' => 'type_of_hide_by',
151 + 'type' => 'button_set',
152 + 'title' => esc_html__('Hide By', 'darkify'),
153 + 'options' => array(
154 + 'user_agent' => esc_html__('User Agent', 'darkify'),
155 + 'screen_size' => esc_html__('Screen Size', 'darkify'),
156 + 'both' => esc_html__('Both', 'darkify'),
157 + ),
158 + 'default' => 'both',
159 + 'dependency' => array('hide_dark_mode_on_mobile', '==', 'true'),
160 + ),
161 + ),
162 + ),
163 + array(
164 + 'id' => 'show_in_menu',
165 + 'type' => 'fieldset',
166 + 'fields' => array(
167 + array(
168 + 'id' => 'enable_switch_in_menu',
169 + 'type' => 'switcher',
170 + 'title' => esc_html__('Show Switch In Menu', 'darkify'),
171 + 'title_help' => '<div class="darkify-info-label">' . __('Show the dark mode toggle switch in specific menu.', 'darkify') . '</div>',
172 + 'text_on' => esc_html__('Yes', 'darkify'),
173 + 'text_off' => esc_html__('No', 'darkify'),
174 + ),
175 + array(
176 + 'id' => 'select_menus',
177 + 'type' => 'group',
178 + 'title' => esc_html__('Select Menus', 'darkify'),
179 + 'accordion_title_number' => true,
180 + 'accordion_title_auto' => true,
181 + 'class' => 'select_menus',
182 + 'max' => '1',
183 + 'add_more_text' => __('Want to use switch in unlimited number of menus? <a target="_blank" href="https://darkifywp.com/pricing/?ref=1"><b>Upgrade To Pro!</b></a>', 'darkify'),
182 184 'fields' => array(
183 - /*
184 - * Which clock drives the schedule. Darkify Lite ships
185 - * only "fixed" (the start/end window below); the
186 - * sunrise/sunset schedule is a Pro feature, so its
187 - * option row carries `pro_only` — the REST layer turns
188 - * that into the `pro_options` stamp the React admin
189 - * renders as a locked, badged preview, and
190 - * strip_pro_keys() refuses to persist the value even
191 - * if a crafted request sends it.
192 - */
193 185 array(
194 - 'id' => 'time_based_dark_mode',
195 - 'type' => 'button_set',
196 - 'default' => 'fixed',
197 - 'options' => array(
198 - 'fixed' => esc_html__('Fixed times', 'darkify'),
199 - 'suncycle' => array(
200 - 'text' => esc_html__('Sunrise & sunset', 'darkify'),
201 - 'pro_only' => true,
202 - ),
203 - ),
186 + 'id' => 'switch_in_menu_location',
187 + 'type' => 'select',
188 + 'class' => 'select_menu_location',
189 + 'title' => esc_html__('Select Menu', 'darkify'),
190 + 'options' => 'menus',
191 + 'empty_message' => esc_html__('You haven\'t created a menu yet. If you\'re using an FSE theme, copy the shortcode below and paste it where you want the switch to appear.', 'darkify'),
204 192 ),
205 193 array(
206 - 'id' => 'time_based_dark_start',
207 - 'type' => 'datetime',
208 - 'after' => esc_html__('From', 'darkify'),
209 - 'placeholder' => esc_html__('From', 'darkify'),
210 - 'settings' => array(
211 - 'noCalendar' => true,
212 - 'enableTime' => true,
213 - 'dateFormat' => 'H:i',
214 - 'time_24hr' => false,
215 - ),
194 + 'id' => 'darkify_menu_shortcode_helper',
195 + 'type' => 'textarea',
196 + 'title' => esc_html__('Shortcode To Add On Menu', 'darkify'),
197 + 'title_help' => '<div class="darkify-info-label">' . __('You can change shortcode options value based on your pereference.', 'darkify') . '</div>',
198 + 'default' => '[darkify switch="1" width="60px" height="60px" icon_size="40px" 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"]'
216 199 ),
217 200 array(
218 - 'id' => 'time_based_dark_end',
219 - 'type' => 'datetime',
220 - 'after' => esc_html__('To', 'darkify'),
221 - 'placeholder' => esc_html__('To', 'darkify'),
222 - 'settings' => array(
223 - 'noCalendar' => true,
224 - 'enableTime' => true,
225 - 'dateFormat' => 'H:i',
226 - 'time_24hr' => false,
201 + 'id' => 'select_menu_position',
202 + 'type' => 'button_set',
203 + 'title' => esc_html__('Select Menu Position', 'darkify'),
204 + 'options' => array(
205 + 'after' => esc_html__('After', 'darkify'),
206 + 'before' => esc_html__('Before', 'darkify'),
227 207 ),
208 + 'default' => 'after',
228 209 ),
229 210 ),
211 + 'dependency' => array('enable_switch_in_menu', '==', 'true'),
230 212 ),
231 213 ),
232 214 ),
233 215 ),
@@ -232,112 +214,33 @@
232 214 ),
233 215 ),
234 216 ),
235 217 array(
236 - 'id' => 'admin',
237 218 'title' => esc_html__('Admin', 'darkify'),
238 219 'icon' => 'icofont-dashboard-web',
239 220 'fields' => array(
240 - // Intro line with a docs link, rendered plain above the section cards.
221 +
241 222 array(
242 - 'type' => 'page_hint',
243 - 'content' => sprintf(
244 - /* translators: %s: documentation link */
245 - __('Bring dark mode to the WordPress admin dashboard and editors. %s', 'darkify'),
246 - '<a href="https://darkifywp.com/docs/" target="_blank" rel="noopener noreferrer">' . esc_html__('View documentation', 'darkify') . '</a>'
247 - ),
248 - ),
249 - // ===== ADMIN APPEARANCE =====
250 - array(
251 - 'type' => 'heading',
252 - 'title' => esc_html__('Admin Appearance', 'darkify'),
253 - 'section_start' => true,
254 - ),
255 - array(
256 223 'id' => 'enable_admin_panel_dark_mode',
257 224 'type' => 'switcher',
258 - 'title' => esc_html__('Admin Panel Dark Mode', 'darkify'),
259 - 'title_help' =>
260 - '<div class="darkify-info-label">' .
261 - __('Enable dark mode in the WordPress admin dashboard.', 'darkify') .
262 - '</div>' .
263 - '' .
264 - '',
265 - 'text_on' => esc_html__('Enabled', 'darkify'),
266 - 'text_off' => esc_html__('Disabled', 'darkify'),
267 - 'default' => false,
268 - 'text_width' => 100,
269 - // Commit instantly even though other fields depend on it.
270 - 'auto_save' => true,
271 - ),
272 -
273 - array(
274 - 'id' => 'block_editor_dark_mode',
275 - 'type' => 'switcher',
276 - 'title' => esc_html__('Block Editor Dark Mode', 'darkify'),
277 - 'title_help' =>
278 - '<div class="darkify-info-label">' .
279 - __('Enable the dark mode switch in the block editor to toggle between dark and light mode.', 'darkify') .
280 - '</div>' .
281 - '' .
282 - '',
283 - 'text_on' => esc_html__('Enabled', 'darkify'),
284 - 'text_off' => esc_html__('Disabled', 'darkify'),
225 + 'title' => esc_html__('Admin Panel Dark Mode', 'darkify'),
226 + 'title_help' => '<div class="darkify-info-label">' . __('Switch to enable Dark Mode in WordPress Admin Panel.', 'darkify') . '</div><a class="tooltip_btn_primary" href="https://darkifywp.com/controls/" target="_blank">' . __('Live Demo', 'darkify') . '</a><a class="tooltip_btn_secondary" href="https://docs.themeatelier.net/docs/darkify-pro/darkify-settings/controls/#admin_controls" target="_blank">' . __('Open Docs', 'darkify') . '</a>',
285 227 'default' => false,
228 + 'text_on' => esc_html__('Enabled', 'darkify'),
229 + 'text_off' => esc_html__('Disabled', 'darkify'),
286 230 'text_width' => 100,
287 231 ),
288 - array(
289 - 'id' => 'classic_editor_dark_mode',
290 - 'type' => 'switcher',
291 - 'title' => esc_html__('Classic Editor Dark Mode', 'darkify'),
292 - 'title_help' =>
293 - '<div class="darkify-info-label">' .
294 - __('Enable the dark mode switch in the classic editor to toggle between dark and light modes.', 'darkify') .
295 - '</div>' .
296 - '' .
297 - '',
298 - 'text_on' => esc_html__('Enabled', 'darkify'),
299 - 'text_off' => esc_html__('Disabled', 'darkify'),
300 232
301 - 'default' => false,
302 - 'text_width' => 100,
303 - ),
304 -
305 - // ===== SCOPE & CUSTOMIZATION =====
306 233 array(
307 - 'type' => 'heading',
308 - 'title' => esc_html__('Scope & Customization', 'darkify'),
309 - 'section_start' => true,
310 - 'dependency' => array('enable_admin_panel_dark_mode', '==', 'true'),
311 - ),
312 - array(
313 234 'id' => 'disallowed_admin_pages',
314 235 'type' => 'textarea',
315 - 'title' => esc_html__('Disallowed Pages', 'darkify'),
316 - 'title_help' => '<div class="darkify-info-text">' .
317 - __('If an admin page URL looks like http://example.com/wp-admin/admin.php?page=darkify, then "darkify" is the page slug.', 'darkify') .
318 - '</div>' .
319 - '' .
320 - '',
321 - 'placeholder' => esc_html__('Enter comma-separated page slugs. Example: darkify-dashboard, elementor', 'darkify'),
236 + 'title' => esc_html__('Disallowed Pages', 'darkify'),
237 + 'title_help' => '<div class="darkify-info-label">' . __('If the admin page URL is like http://example.com/wp-admin/admin.php?page=darkify then darkify is it\'s page slug.', 'darkify') . '</div>',
238 + 'placeholder' => esc_html__('Enter comma separated page slugs. Example: darkify-dashboard, elementor', 'darkify'),
322 239 'dependency' => array('enable_admin_panel_dark_mode', '==', 'true'),
323 240 'class' => 'only_pro'
324 241 ),
325 - array(
326 - 'id' => 'admin_custom_css',
327 - 'type' => 'code_editor',
328 - 'title' => esc_html__('Admin Dark Mode CSS', 'darkify'),
329 - 'title_help' =>
330 - '<div class="darkify-info-label">' .
331 - __('The CSS code will only be applied when admin dark mode is active.', 'darkify') .
332 - '</div>',
333 - 'settings' => array(
334 - 'theme' => 'mbo',
335 - 'mode' => 'css',
336 - ),
337 - // Only relevant when admin dark mode is active — hide it while off.
338 - 'dependency' => array('enable_admin_panel_dark_mode', '==', 'true'),
339 - ),
242 +
340 243 ),
341 244 ),
342 245 ),
343 246 ),