PluginProbe
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) / 1.5.3
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) v1.5.3
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 / Framework / Classes / DarkifyOptions.php

DarkifyOptions.php in Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) 1.5.3, at src/Admin/Framework/Classes/DarkifyOptions.php

681 lines 26.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use ThemeAtelier\Darkify\Admin\Framework\Classes\Darkify;
4
5 if (! defined('ABSPATH')) {
6 die;
7 } // Cannot access directly.
8 /**
9 *
10 * Options Class
11 *
12 * @since 1.0.0
13 * @version 1.0.0
14 *
15 */
16 if (! class_exists('DarkifyOptions')) {
17 class DarkifyOptions extends DarkifyAbstract
18 {
19
20 // constans
21 public $unique = '';
22 public $notice = '';
23 public $abstract = 'options';
24 public $sections = array();
25 public $options = array();
26 public $errors = array();
27 public $pre_tabs = array();
28 public $pre_fields = array();
29 public $pre_sections = array();
30 public $args = array(
31
32 // framework title
33 'framework_title' => 'Codestar Framework <small>by Codestar</small>',
34 'framework_class' => '',
35
36 // menu settings
37 'menu_title' => '',
38 'menu_slug' => '',
39 'menu_type' => 'menu',
40 'menu_capability' => 'manage_options',
41 'menu_icon' => null,
42 'menu_position' => null,
43 'menu_hidden' => false,
44 'menu_parent' => '',
45 'sub_menu_title' => '',
46
47 // menu extras
48 'show_bar_menu' => true,
49 'show_sub_menu' => true,
50 'show_in_network' => true,
51 'show_in_customizer' => false,
52
53 'show_search' => true,
54 'show_reset_all' => true,
55 'show_reset_section' => true,
56 'show_footer' => true,
57 'show_all_options' => true,
58 'show_form_warning' => true,
59 'sticky_header' => true,
60 'save_defaults' => true,
61 'ajax_save' => true,
62 'form_action' => '',
63
64 // admin bar menu settings
65 'admin_bar_menu_icon' => '',
66 'admin_bar_menu_priority' => 50,
67
68 // footer
69 'footer_text' => 'Thank you for creating with Codestar Framework',
70 'footer_after' => '',
71 'footer_credit' => '',
72
73 // database model
74 'database' => '', // options, transient, theme_mod, network
75 'transient_time' => 0,
76
77 // contextual help
78 'contextual_help' => array(),
79 'contextual_help_sidebar' => '',
80
81 // others
82 'output_css' => true,
83
84 // theme
85 'nav' => 'normal',
86 'theme' => 'dark',
87 'class' => '',
88
89 // external default values
90 'defaults' => array(),
91
92 );
93
94 // run framework construct
95 public function __construct($key, $params = array())
96 {
97
98 $this->unique = $key;
99 $this->args = apply_filters("darkify_{$this->unique}_args", wp_parse_args($params['args'], $this->args), $this);
100 $this->sections = apply_filters("darkify_{$this->unique}_sections", $params['sections'], $this);
101
102 // run only is admin panel options, avoid performance loss
103 $this->pre_tabs = $this->pre_tabs($this->sections);
104 $this->pre_fields = $this->pre_fields($this->sections);
105 $this->pre_sections = $this->pre_sections($this->sections);
106
107 $this->get_options();
108 $this->set_options();
109 $this->save_defaults();
110
111 add_action('admin_menu', array($this, 'add_admin_menu'));
112 add_action('admin_bar_menu', array($this, 'add_admin_bar_menu'), $this->args['admin_bar_menu_priority']);
113 add_action('wp_ajax_darkify_' . $this->unique . '_ajax_save', array($this, 'ajax_save'));
114
115 if ($this->args['database'] === 'network' && ! empty($this->args['show_in_network'])) {
116 add_action('network_admin_menu', array($this, 'add_admin_menu'));
117 }
118 }
119
120 // instance
121 public static function instance($key, $params = array())
122 {
123 return new self($key, $params);
124 }
125
126 // add admin bar menu
127 public function add_admin_bar_menu($wp_admin_bar)
128 {
129
130 if (! current_user_can($this->args['menu_capability'])) {
131 return;
132 }
133
134 if (is_network_admin() && ($this->args['database'] !== 'network' || $this->args['show_in_network'] !== true)) {
135 return;
136 }
137
138 if (! empty($this->args['show_bar_menu']) && empty($this->args['menu_hidden'])) {
139
140 global $submenu;
141
142 $menu_slug = $this->args['menu_slug'];
143 $menu_icon = (! empty($this->args['admin_bar_menu_icon'])) ? '<span class="darkify-ab-icon ab-icon ' . esc_attr($this->args['admin_bar_menu_icon']) . '"></span>' : '';
144
145 $wp_admin_bar->add_node(array(
146 'id' => $menu_slug,
147 'title' => $menu_icon . esc_attr($this->args['menu_title']),
148 'href' => esc_url((is_network_admin()) ? network_admin_url('admin.php?page=' . $menu_slug) : admin_url('admin.php?page=' . $menu_slug)),
149 ));
150
151 if (! empty($submenu[$menu_slug])) {
152 foreach ($submenu[$menu_slug] as $menu_key => $menu_value) {
153 $wp_admin_bar->add_node(array(
154 'parent' => $menu_slug,
155 'id' => $menu_slug . '-' . $menu_key,
156 'title' => $menu_value[0],
157 'href' => esc_url((is_network_admin()) ? network_admin_url('admin.php?page=' . $menu_value[2]) : admin_url('admin.php?page=' . $menu_value[2])),
158 ));
159 }
160 }
161 }
162 }
163
164 public function ajax_save()
165 {
166
167 $result = $this->set_options(true);
168
169 if (! $result) {
170 wp_send_json_error(array('error' => esc_html__('Error while saving the changes.', 'darkify')));
171 } else {
172 wp_send_json_success(array('notice' => $this->notice, 'errors' => $this->errors));
173 }
174 }
175
176 // get default value
177 public function get_default($field)
178 {
179
180 $default = (isset($field['default'])) ? $field['default'] : '';
181 $default = (isset($this->args['defaults'][$field['id']])) ? $this->args['defaults'][$field['id']] : $default;
182
183 return $default;
184 }
185
186 // save defaults and set new fields value to main options
187 public function save_defaults()
188 {
189
190 $tmp_options = $this->options;
191
192 foreach ($this->pre_fields as $field) {
193 if (! empty($field['id'])) {
194 $this->options[$field['id']] = (isset($this->options[$field['id']])) ? $this->options[$field['id']] : $this->get_default($field);
195 }
196 }
197
198 if ($this->args['save_defaults'] && empty($tmp_options)) {
199 $this->save_options($this->options);
200 }
201 }
202
203 // set options
204 public function set_options($ajax = false)
205 {
206
207 // XSS ok.
208 // No worries, This "POST" requests is sanitizing in the below foreach. see #L337 - #L341
209 $response = ($ajax && ! empty($_POST['data'])) ? json_decode(wp_unslash(trim($_POST['data'])), true) : $_POST;
210
211 // Set variables.
212 $data = array();
213 $noncekey = 'darkify_options_nonce' . $this->unique;
214 $nonce = (! empty($response[$noncekey])) ? $response[$noncekey] : '';
215 $options = (! empty($response[$this->unique])) ? $response[$this->unique] : array();
216 $transient = (! empty($response['darkify_transient'])) ? $response['darkify_transient'] : array();
217
218 if (wp_verify_nonce($nonce, 'darkify_options_nonce')) {
219
220 $importing = false;
221 $section_id = (! empty($transient['section'])) ? $transient['section'] : '';
222
223 if (! $ajax && ! empty($response['darkify_import_data'])) {
224
225 // XSS ok.
226 // No worries, This "POST" requests is sanitizing in the below foreach. see #L337 - #L341
227 $import_data = json_decode(wp_unslash(trim($response['darkify_import_data'])), true);
228 $options = (is_array($import_data) && ! empty($import_data)) ? $import_data : array();
229 $importing = true;
230 $this->notice = esc_html__('Settings successfully imported.', 'darkify');
231 }
232
233 if (! empty($transient['reset'])) {
234
235 foreach ($this->pre_fields as $field) {
236 if (! empty($field['id'])) {
237 $data[$field['id']] = $this->get_default($field);
238 }
239 }
240
241 $this->notice = esc_html__('Default settings restored.', 'darkify');
242 } else if (! empty($transient['reset_section']) && ! empty($section_id)) {
243
244 if (! empty($this->pre_sections[$section_id - 1]['fields'])) {
245 foreach ($this->pre_sections[$section_id - 1]['fields'] as $field) {
246 if ('section_tab' === $field['type'] || 'section_inner_tab' === $field['type']) {
247 $tabs = $field['tabs'];
248 foreach ($tabs as $fields) {
249 $fields = $fields['fields'];
250 foreach ($fields as $field) {
251 if (isset($field['id'])) {
252 $data[$field['id']] = $this->get_default($field);
253 }
254 }
255 }
256
257 } else {
258 if (!empty($field['id'])) {
259 $data[$field['id']] = $this->get_default($field);
260 }
261 }
262 }
263 }
264
265 $data = wp_parse_args($data, $this->options);
266
267 $this->notice = esc_html__('Default settings restored.', 'darkify');
268 } else {
269
270 // sanitize and validate
271 foreach ($this->pre_fields as $field) {
272
273
274 if ('section_tab' === $field['type'] || 'section_inner_tab' === $field['type']) {
275 $tabs = $field['tabs'];
276
277 foreach ($tabs as $fields) {
278 $fields = $fields['fields'];
279 foreach ($fields as $field) {
280 $field_id = isset($field['id']) ? $field['id'] : '';
281 $field_value = isset($options[$field_id]) ? $options[$field_id] : '';
282 // Ajax and Importing doing wp_unslash already.
283 if (!$ajax && !$importing) {
284 $field_value = wp_unslash($field_value);
285 }
286 // Sanitize "post" request of field.
287 if (!isset($field['sanitize'])) {
288 if (is_array($field_value)) {
289 $data[$field_id] = wp_kses_post_deep($field_value);
290 } else {
291 $data[$field_id] = wp_kses_post($field_value);
292 }
293 } elseif (isset($field['sanitize']) && is_callable($field['sanitize'])) {
294 $data[$field_id] = call_user_func($field['sanitize'], $field_value);
295 } else {
296 $data[$field_id] = $field_value;
297 }
298
299 // Validate "post" request of field.
300 if (isset($field['validate']) && is_callable($field['validate'])) {
301 $has_validated = call_user_func($field['validate'], $field_value);
302 if (!empty($has_validated)) {
303 $data[$field_id] = (isset($this->options[$field_id])) ? $this->options[$field_id] : '';
304 $this->errors[$field_id] = $has_validated;
305 }
306 }
307 }
308 }
309 } elseif (!empty($field['id'])) {
310 $field_id = $field['id'];
311 $field_value = isset($options[$field_id]) ? $options[$field_id] : '';
312 // Ajax and Importing doing wp_unslash already.
313 if (!$ajax && !$importing) {
314 $field_value = wp_unslash($field_value);
315 }
316 // Sanitize "post" request of field.
317 if (!isset($field['sanitize'])) {
318 if (is_array($field_value)) {
319 $data[$field_id] = wp_kses_post_deep($field_value);
320 } else {
321 $data[$field_id] = wp_kses_post($field_value);
322 }
323 } elseif (isset($field['sanitize']) && is_callable($field['sanitize'])) {
324 $data[$field_id] = call_user_func($field['sanitize'], $field_value);
325 } else {
326 $data[$field_id] = $field_value;
327 }
328
329 // Validate "post" request of field.
330 if (isset($field['validate']) && is_callable($field['validate'])) {
331
332 $has_validated = call_user_func($field['validate'], $field_value);
333
334 if (!empty($has_validated)) {
335
336 $data[$field_id] = (isset($this->options[$field_id])) ? $this->options[$field_id] : '';
337 $this->errors[$field_id] = $has_validated;
338 }
339 }
340 }
341 }
342 }
343
344 $data = apply_filters("darkify_{$this->unique}_save", $data, $this);
345
346 do_action("darkify_{$this->unique}_save_before", $data, $this);
347
348 $this->options = $data;
349
350 $this->save_options($data);
351
352 do_action("darkify_{$this->unique}_save_after", $data, $this);
353
354 return true;
355 }
356
357 return false;
358 }
359
360 // save options database
361 public function save_options($data)
362 {
363
364 if ($this->args['database'] === 'transient') {
365 set_transient($this->unique, $data, $this->args['transient_time']);
366 } else if ($this->args['database'] === 'theme_mod') {
367 set_theme_mod($this->unique, $data);
368 } else if ($this->args['database'] === 'network') {
369 update_site_option($this->unique, $data);
370 } else {
371 update_option($this->unique, $data);
372 }
373
374 do_action("darkify_{$this->unique}_saved", $data, $this);
375 }
376
377 // get options from database
378 public function get_options()
379 {
380
381 if ($this->args['database'] === 'transient') {
382 $this->options = get_transient($this->unique);
383 } else if ($this->args['database'] === 'theme_mod') {
384 $this->options = get_theme_mod($this->unique);
385 } else if ($this->args['database'] === 'network') {
386 $this->options = get_site_option($this->unique);
387 } else {
388 $this->options = get_option($this->unique);
389 }
390
391 if (empty($this->options)) {
392 $this->options = array();
393 }
394
395 return $this->options;
396 }
397
398 // admin menu
399 public function add_admin_menu()
400 {
401
402 extract($this->args);
403
404 if ($menu_type === 'submenu') {
405
406 $menu_page = call_user_func('add_submenu_page', $menu_parent, esc_attr($menu_title), esc_attr($menu_title), $menu_capability, $menu_slug, array($this, 'add_options_html'));
407 } else {
408
409 $menu_page = call_user_func('add_menu_page', esc_attr($menu_title), esc_attr($menu_title), $menu_capability, $menu_slug, array($this, 'add_options_html'), $menu_icon, $menu_position);
410
411 if (! empty($sub_menu_title)) {
412 call_user_func('add_submenu_page', $menu_slug, esc_attr($sub_menu_title), esc_attr($sub_menu_title), $menu_capability, $menu_slug, array($this, 'add_options_html'));
413 }
414
415 if (! empty($this->args['show_sub_menu']) && count($this->pre_tabs) > 1) {
416
417 // create submenus
418 foreach ($this->pre_tabs as $section) {
419 call_user_func('add_submenu_page', $menu_slug, esc_attr($section['title']), esc_attr($section['title']), $menu_capability, $menu_slug . '#tab=' . sanitize_title($section['title']), '__return_null');
420 }
421
422 remove_submenu_page($menu_slug, $menu_slug);
423 }
424
425 if (! empty($menu_hidden)) {
426 remove_menu_page($menu_slug);
427 }
428 }
429
430 add_action('load-' . $menu_page, array($this, 'add_page_on_load'));
431 }
432
433 public function add_page_on_load()
434 {
435
436 if (! empty($this->args['contextual_help'])) {
437
438 $screen = get_current_screen();
439
440 foreach ($this->args['contextual_help'] as $tab) {
441 $screen->add_help_tab($tab);
442 }
443
444 if (! empty($this->args['contextual_help_sidebar'])) {
445 $screen->set_help_sidebar($this->args['contextual_help_sidebar']);
446 }
447 }
448
449 if (! empty($this->args['footer_credit'])) {
450 add_filter('admin_footer_text', array($this, 'add_admin_footer_text'));
451 }
452 }
453
454 public function add_admin_footer_text()
455 {
456 echo wp_kses_post($this->args['footer_credit']);
457 }
458
459 public function error_check($sections, $err = '')
460 {
461
462 if (! $this->args['ajax_save']) {
463
464 if (! empty($sections['fields'])) {
465 foreach ($sections['fields'] as $field) {
466 if (! empty($field['id'])) {
467 if (array_key_exists($field['id'], $this->errors)) {
468 $err = '<span class="darkify-label-error">!</span>';
469 }
470 }
471 }
472 }
473
474 if (! empty($sections['subs'])) {
475 foreach ($sections['subs'] as $sub) {
476 $err = $this->error_check($sub, $err);
477 }
478 }
479
480 if (! empty($sections['id']) && array_key_exists($sections['id'], $this->errors)) {
481 $err = $this->errors[$sections['id']];
482 }
483 }
484
485 return $err;
486 }
487
488 // option page html output
489 public function add_options_html()
490 {
491
492 $has_nav = (count($this->pre_tabs) > 1) ? true : false;
493 $show_all = (! $has_nav) ? ' darkify-show-all' : '';
494 $ajax_class = ($this->args['ajax_save']) ? ' darkify-save-ajax' : '';
495 $sticky_class = ($this->args['sticky_header']) ? ' darkify-sticky-header' : '';
496 $wrapper_class = ($this->args['framework_class']) ? ' ' . $this->args['framework_class'] : '';
497 $theme = ($this->args['theme']) ? ' darkify-theme-' . $this->args['theme'] : '';
498 $class = ($this->args['class']) ? ' ' . $this->args['class'] : '';
499 $nav_type = ($this->args['nav'] === 'inline') ? 'inline' : 'normal';
500 $form_action = ($this->args['form_action']) ? $this->args['form_action'] : '';
501
502 do_action('darkify_options_before');
503
504 echo '<div class="darkify darkify-options' . esc_attr($theme . $class . $wrapper_class) . '" data-slug="' . esc_attr($this->args['menu_slug']) . '" data-unique="' . esc_attr($this->unique) . '">';
505
506 echo '<div class="darkify-container">';
507
508 echo '<form method="post" action="' . esc_attr($form_action) . '" enctype="multipart/form-data" id="darkify-form" autocomplete="off" novalidate="novalidate">';
509
510 echo '<input type="hidden" class="darkify-section-id" name="darkify_transient[section]" value="1">';
511
512 wp_nonce_field('darkify_options_nonce', 'darkify_options_nonce' . $this->unique);
513
514 echo '<div class="darkify-header' . esc_attr($sticky_class) . '">';
515 echo '<div class="darkify-header-inner">';
516 echo '<div class="darkify-admin-header">';
517 echo '<div class="darkify-header-left">';
518 echo '<img src="' . esc_url(DARKIFY_ASSETS . '/img/darkify-icon.svg') . '" alt="'. esc_html__('Darkify dark mode plugin', 'darkify') .'"/>';
519 echo '<h1>' . esc_html($this->args['framework_title']) . '</h1>';
520 echo '<div class="darkify-version">v' . esc_html(DARKIFY_VERSION) . '</div>';
521 echo '</div>';
522
523 echo '<div class="darkify-header-right">';
524
525 $notice_class = (! empty($this->notice)) ? 'darkify-form-show' : '';
526 $notice_text = (! empty($this->notice)) ? $this->notice : '';
527
528 echo '<div class="darkify-form-result darkify-form-success ' . esc_attr($notice_class) . '">' . wp_kses_post($notice_text) . '</div>';
529
530 echo ($has_nav && $this->args['show_all_options']) ? '<div class="darkify-expand-all" title="' . esc_html__('show all settings', 'darkify') . '"><i class="icofont-outdent"></i></div>' : '';
531
532 echo ($this->args['show_search']) ? '<div class="darkify-search"><input type="text" name="darkify-search" placeholder="' . esc_html__('Search...', 'darkify') . '" autocomplete="off" /></div>' : '';
533
534 echo '<div class="darkify-buttons">';
535 echo '<input type="submit" name="' . esc_attr($this->unique) . '[_nonce][save]" class="button button-primary darkify-top-save darkify-save' . esc_attr($ajax_class) . '" value="' . esc_html__('Save Settings', 'darkify') . '" data-save="' . esc_html__('Saving...', 'darkify') . '">';
536 echo ($this->args['show_reset_section']) ? '<input type="submit" name="darkify_transient[reset_section]" class="button button-secondary darkify-reset-section darkify-confirm" value="' . esc_html__('Reset Tab', 'darkify') . '" data-confirm="' . esc_html__('Are you sure to reset this section options?', 'darkify') . '">' : '';
537 echo ($this->args['show_reset_all']) ? '<input type="submit" name="darkify_transient[reset]" class="button darkify-warning-primary darkify-reset-all darkify-confirm" value="' . (($this->args['show_reset_section']) ? esc_html__('Reset All', 'darkify') : esc_html__('Reset', 'darkify')) . '" data-confirm="' . esc_html__('Are you sure you want to reset all settings to default values?', 'darkify') . '">' : '';
538 echo '</div>';
539
540 echo '</div>';
541
542 echo '<div class="clear"></div>';
543 echo '</div>';
544 echo '</div>';
545 echo '</div>';
546
547 echo '<div class="darkify-wrapper' . esc_attr($show_all) . '">';
548
549 if ($has_nav) {
550
551 echo '<div class="darkify-nav darkify-nav-' . esc_attr($nav_type) . ' darkify-nav-options">';
552
553 echo '<ul>';
554
555 foreach ($this->pre_tabs as $tab) {
556
557 $tab_id = sanitize_title($tab['title']);
558 $tab_error = $this->error_check($tab);
559 $tab_icon = (! empty($tab['icon'])) ? '<i class="darkify-tab-icon ' . esc_attr($tab['icon']) . '"></i>' : '';
560
561 if (! empty($tab['subs'])) {
562
563 echo '<li class="darkify-tab-item">';
564
565 echo '<a href="#tab=' . esc_attr($tab_id) . '" data-tab-id="' . esc_attr($tab_id) . '" class="darkify-arrow">' . wp_kses_post($tab_icon) . wp_kses_post($tab['title']) . wp_kses_post($tab_error) . '</a>';
566
567 echo '<ul>';
568
569 foreach ($tab['subs'] as $sub) {
570
571 $sub_id = $tab_id . '/' . sanitize_title($sub['title']);
572 $sub_error = $this->error_check($sub);
573 $sub_icon = (! empty($sub['icon'])) ? '<i class="darkify-tab-icon ' . esc_attr($sub['icon']) . '"></i>' : '';
574
575 echo '<li><a href="#tab=' . esc_attr($sub_id) . '" data-tab-id="' . esc_attr($sub_id) . '">' . wp_kses_post($sub_icon) . wp_kses_post($sub['title']) . wp_kses_post($sub_error) . '</a></li>';
576 }
577
578 echo '</ul>';
579
580 echo '</li>';
581 } else {
582
583 echo '<li class="darkify-tab-item"><a href="#tab=' . esc_attr($tab_id) . '" data-tab-id="' . esc_attr($tab_id) . '">' . wp_kses_post($tab_icon) . wp_kses_post($tab['title']) . wp_kses_post($tab_error) . '</a></li>';
584 }
585 }
586
587 echo '</ul>';
588
589 echo '</div>';
590 }
591
592 echo '<div class="darkify-content">';
593
594 echo '<div class="darkify-sections">';
595
596 foreach ($this->pre_sections as $section) {
597
598 $section_onload = (! $has_nav) ? ' darkify-onload' : '';
599 $section_class = (! empty($section['class'])) ? ' ' . $section['class'] : '';
600 $section_icon = (! empty($section['icon'])) ? '<i class="darkify-section-icon ' . esc_attr($section['icon']) . '"></i>' : '';
601 $section_title = (! empty($section['title'])) ? $section['title'] : '';
602 $section_parent = (! empty($section['ptitle'])) ? sanitize_title($section['ptitle']) . '/' : '';
603 $section_slug = (! empty($section['title'])) ? sanitize_title($section_title) : '';
604
605 echo '<div class="darkify-section hidden' . esc_attr($section_onload . $section_class) . '" data-section-id="' . esc_attr($section_parent . $section_slug) . '">';
606 echo ($has_nav) ? '<div class="darkify-section-title"><h3>' .wp_kses_post( $section_icon ) . wp_kses_post($section_title) . '</h3></div>' : '';
607 echo (! empty($section['description'])) ? '<div class="darkify-field darkify-section-description">' . wp_kses_post($section['description']) . '</div>' : '';
608
609 if (! empty($section['fields'])) {
610
611 foreach ($section['fields'] as $field) {
612
613 $is_field_error = $this->error_check($field);
614
615 if (! empty($is_field_error)) {
616 $field['_error'] = $is_field_error;
617 }
618
619 if (! empty($field['id'])) {
620 $field['default'] = $this->get_default($field);
621 }
622
623 if ('section_tab' === $field['type']) { // field type section_tab, no field id.
624 $value = $this->options;
625 } elseif ( 'section_inner_tab' === $field['type']) { // field type section_inner_tab, no field id.
626 $value = $this->options;
627 } else {
628 $value = (!empty($field['id']) && isset($this->options[$field['id']])) ? $this->options[$field['id']] : '';
629 }
630
631 Darkify::field($field, $value, $this->unique, 'options');
632 }
633 } else {
634
635 echo '<div class="darkify-no-option">' . esc_html__('No data available.', 'darkify') . '</div>';
636 }
637
638 echo '</div>';
639 }
640
641 echo '</div>';
642
643 echo '<div class="clear"></div>';
644
645 echo '</div>';
646
647 echo ($has_nav && $nav_type === 'normal') ? '<div class="darkify-nav-background"></div>' : '';
648
649 echo '</div>';
650
651 if (! empty($this->args['show_footer'])) {
652
653 echo '<div class="darkify-footer">';
654
655 echo '<div class="darkify-buttons">';
656 echo '<input type="submit" name="darkify_transient[save]" class="button button-primary darkify-save' . esc_attr($ajax_class) . '" value="' . esc_html__('Save', 'darkify') . '" data-save="' . esc_html__('Saving...', 'darkify') . '">';
657 echo ($this->args['show_reset_section']) ? '<input type="submit" name="darkify_transient[reset_section]" class="button button-secondary darkify-reset-section darkify-confirm" value="' . esc_html__('Reset Tab', 'darkify') . '" data-confirm="' . esc_html__('Are you sure to reset this section options?', 'darkify') . '">' : '';
658 echo ($this->args['show_reset_all']) ? '<input type="submit" name="darkify_transient[reset]" class="button darkify-warning-primary darkify-reset-all darkify-confirm" value="' . (($this->args['show_reset_section']) ? esc_html__('Reset All', 'darkify') : esc_html__('Reset', 'darkify')) . '" data-confirm="' . esc_html__('Are you sure you want to reset all settings to default values?', 'darkify') . '">' : '';
659 echo '</div>';
660
661 echo (! empty($this->args['footer_text'])) ? '<div class="darkify-copyright">' . wp_kses_post($this->args['footer_text']) . '</div>' : '';
662
663 echo '<div class="clear"></div>';
664 echo '</div>';
665 }
666
667 echo '</form>';
668
669 echo '</div>';
670
671 echo '<div class="clear"></div>';
672
673 echo (! empty($this->args['footer_after'])) ? wp_kses_post($this->args['footer_after']) : '';
674
675 echo '</div>';
676
677 do_action('darkify_options_after');
678 }
679 }
680 }
681