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 / Frontend / Templates / header_script.php

header_script.php in Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) 1.5.3, at src/Frontend/Templates/header_script.php

206 lines 12.1 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\Includes\DarkifyUtils;
4 // don't call the file directly.
5 if (!defined('ABSPATH')) {
6 exit;
7 }
8
9 ob_start();
10 $options = get_option('darkify');
11 $enable_default_dark_mode = isset($options['enable_default_dark_mode']) ? $options['enable_default_dark_mode'] : '';
12 $enable_os_aware = isset($options['enable_os_aware']) ? $options['enable_os_aware'] : true;
13 $enable_keyboard_shortcut = isset($options['enable_keyboard_shortcut']) ? $options['enable_keyboard_shortcut'] : true;
14 $enable_time = isset($options['enable_time']) ? $options['enable_time'] : "";
15 $enable_time_based_dark = isset($enable_time['enable_time_based_dark']) ? $enable_time['enable_time_based_dark'] : "";
16 $enable_time_fields = isset($enable_time['enable_time_fields']) ? $enable_time['enable_time_fields'] : '';
17 $time_based_dark_start = isset($enable_time_fields['time_based_dark_start']) ? $enable_time_fields['time_based_dark_start'] : "";
18 $time_based_dark_stop = isset($enable_time_fields['time_based_dark_end']) ? $enable_time_fields['time_based_dark_end'] : "";
19
20 // Extras
21 $enable_scrollbar_dark = isset($options["enable_scrollbar_dark"]) ? $options["enable_scrollbar_dark"] : true;
22 $alternative_dark_mode_switcher = isset($options['alternative_dark_mode_switcher']) ? $options['alternative_dark_mode_switcher'] : "";
23 $enable_switch_attention = isset($options['enable_switch_attention']) ? $options['enable_switch_attention'] : '';
24 $switch_attention_effect = isset($options['switch_attention_effect']) ? $options['switch_attention_effect'] : 'pulse';
25 if ($switch_attention_effect !== 'pulse') { $switch_attention_effect = 'pulse'; }
26
27 // Image Control
28 $brightness = isset($options['brightness']) ? $options['brightness'] : "";
29 $enable_low_image_brightness = isset($brightness['enable_low_image_brightness']) ? $brightness['enable_low_image_brightness'] : "1";
30 $low_image_brightness_label = isset($brightness['low_image_brightness_label']) ? 100 - $brightness['low_image_brightness_label'] : 100 - "20";
31
32 $grayscale = isset($options['grayscale']) ? $options['grayscale'] : "";
33 $enable_image_grayscale = isset($grayscale['enable_image_grayscale']) ? $grayscale['enable_image_grayscale'] : "";
34 $image_grayscale_label = isset($grayscale['image_grayscale_label']) ? $grayscale['image_grayscale_label'] : "80";
35
36 $darken_background = isset($options['darken_background']) ? $options['darken_background'] : "";
37 $enable_low_image_darken = isset($darken_background['enable_low_image_darken']) ? $darken_background['enable_low_image_darken'] : "1";
38 $low_image_darken_label = isset($darken_background['low_image_darken_label']) ? $darken_background['low_image_darken_label'] : "60";
39
40 $enable_invert_inline_svg = isset($options['enable_invert_inline_svg']) ? $options['enable_invert_inline_svg'] : "";
41
42 // Video Control
43 $video_brightness = isset($options['video_brightness']) ? $options['video_brightness'] : "";
44 $enable_low_video_brightness = isset($video_brightness['enable_low_video_brightness']) ? $video_brightness['enable_low_video_brightness'] : true;
45 $low_video_brightness_label = isset($video_brightness['low_video_brightness_label']) ? 100 - $video_brightness['low_video_brightness_label'] : 100 - "20";
46
47 $video_grayscale = isset($options['video_grayscale']) ? $options['video_grayscale'] : '';
48 $enable_video_grayscale = isset($video_grayscale['enable_video_grayscale']) ? $video_grayscale['enable_video_grayscale'] : "";
49 $video_grayscale_label = isset($video_grayscale['video_grayscale_label']) ? $video_grayscale['video_grayscale_label'] : "80";
50
51
52 if (!is_admin()) { ?>
53 <style type="text/css" class="darkify_inline_css">
54 :root {
55 <?php
56 $dark_mode_color_palettes = [
57 'set1' => [
58 'bg' => isset($options["dark_mode_color_set1"]) ? $options["dark_mode_color_set1"]['background'] : '#0F0F0F',
59 'secondary_bg' => isset($options["dark_mode_color_set1"]) ? $options["dark_mode_color_set1"]['secondary_background'] : '#171717',
60 'text_color' => '#BEBEBE',
61 'link_color' => '#E7E7E7',
62 'link_hover_color' => '#BEBEBE',
63 'input_bg' => '#2D2D2D',
64 'input_text_color' => '#BEBEBE',
65 'input_placeholder_color' => '#BEBEBE',
66 'border_color' => '#4A4A4A',
67 'btn_text_color' => '#BEBEBE',
68 'btn_bg' => '#4A4A4A',
69 'btn_text_hover_color' => '#BEBEBE',
70 'btn_hover_bg' => '#2D2D2D',
71 ],
72 'set3' => [
73 'bg' => isset($options["dark_mode_color_set3"]) ? $options["dark_mode_color_set3"]['background'] : '#211e3c',
74 'secondary_bg' => isset($options["dark_mode_color_set3"]) ? $options["dark_mode_color_set3"]['secondary_background'] : '#302C57',
75 'text_color' => '#B1BBD8',
76 'link_color' => '#8071fb',
77 'link_hover_color' => '#B1BBD8',
78 'input_bg' => '#2A264D',
79 'input_text_color' => '#B1BBD8',
80 'input_placeholder_color' => '#B1BBD8',
81 'border_color' => '#4E478D',
82 'btn_text_color' => '#B1BBD8',
83 'btn_bg' => '#4E478D',
84 'btn_text_hover_color' => '#B1BBD8',
85 'btn_hover_bg' => '#2A264D',
86 ],
87 'set9' => [
88 'bg' => isset($options["dark_mode_color_set9"]) ? $options["dark_mode_color_set9"]['background'] : '#04261d',
89 'secondary_bg' => isset($options["dark_mode_color_set9"]) ? $options["dark_mode_color_set9"]['secondary_background'] : '#021e16',
90 'text_color' => '#C1D2BB',
91 'link_color' => '#00d29a',
92 'link_hover_color' => '#C1D2BB',
93 'input_bg' => '#073d2f',
94 'input_text_color' => '#C1D2BB',
95 'input_placeholder_color' => '#C1D2BB',
96 'border_color' => '#095541',
97 'btn_text_color' => '#C1D2BB',
98 'btn_bg' => '#095541',
99 'btn_text_hover_color' => '#C1D2BB',
100 'btn_hover_bg' => '#073d2f',
101 ],
102 'set6' => [
103 'bg' => isset($options["dark_mode_color_set6"]) ? $options["dark_mode_color_set6"]['background'] : '#082032',
104 'secondary_bg' => isset($options["dark_mode_color_set6"]) ? $options["dark_mode_color_set6"]['secondary_background'] : '#061825',
105 'text_color' => '#B5D9F3',
106 'link_color' => '#61bbff',
107 'link_hover_color' => '#B5D9F3',
108 'input_bg' => '#0E3755',
109 'input_text_color' => '#B5D9F3',
110 'input_placeholder_color' => '#B5D9F3',
111 'border_color' => '#144E78',
112 'btn_text_color' => '#B5D9F3',
113 'btn_bg' => '#144E78',
114 'btn_text_hover_color' => '#B5D9F3',
115 'btn_hover_bg' => '#0E3755',
116 ],
117 'set10' => [
118 'bg' => isset($options["dark_mode_color_set10"]) ? $options["dark_mode_color_set10"]['background'] : '#171004',
119 'secondary_bg' => isset($options["dark_mode_color_set10"]) ? $options["dark_mode_color_set10"]['secondary_background'] : '#211706',
120 'text_color' => '#E0D2BD',
121 'link_color' => '#e09525',
122 'link_hover_color' => '#E0D2BD',
123 'input_bg' => '#372911',
124 'input_text_color' => '#E0D2BD',
125 'input_placeholder_color' => '#E0D2BD',
126 'border_color' => '#5D4010',
127 'btn_text_color' => '#E0D2BD',
128 'btn_bg' => '#5D4010',
129 'btn_text_hover_color' => '#E0D2BD',
130 'btn_hover_bg' => '#372911',
131 ],
132 ];
133
134
135 $selected_set_key = isset($options['color_pallets']) ? $options['color_pallets'] : 'set1';
136 $selected_set = $dark_mode_color_palettes[$selected_set_key] ?? $dark_mode_color_palettes['set1'];
137
138 // Output as CSS variables
139 foreach ($selected_set as $key => $value) {
140 echo '--darkify_dark_mode_' . esc_attr($key) . ': ' . esc_attr($value) . ';';
141 }
142 ?>
143 }
144 </style>
145 <?php } else { ?>
146 <style type="text/css" class="darkify_inline_css">
147 :root {
148 --darkify_dark_mode_bg: #181a1b;
149 --darkify_dark_mode_secondary_bg: #202324;
150 --darkify_dark_mode_text_color: #c8c4bd;
151 --darkify_dark_mode_link_color: #6aafe2;
152 --darkify_dark_mode_link_hover_color: #4f94c3;
153 --darkify_dark_mode_input_bg: #2D2D2D;
154 --darkify_dark_mode_input_text_color: #BEBEBE;
155 --darkify_dark_mode_input_placeholder_color: #989898;
156 --darkify_dark_mode_border_color: #4A4A4A;
157 --darkify_dark_mode_btn_bg: #2D2D2D;
158 --darkify_dark_mode_btn_text_color: #BEBEBE;
159 --darkify_dark_mode_btn_hover_bg: #BEBEBE;
160 --darkify_dark_mode_btn_text_hover_color: #2D2D2D;
161 }
162 </style>
163 <?php }
164
165 if ($enable_scrollbar_dark) {
166 $dark_mode_scrollbar_track_bg = '#29292a';
167 $dark_mode_scrollbar_thumb_bg = '#52565a';
168 include DarkifyUtils::darkify_locate_template('views/scrollbar.php');
169 }
170 ?>
171
172 <script type="text/javascript" class="darkify_inline_js">
173 var darkify_switch_unique_id = "<?php echo esc_attr($this->unique_id); ?>";
174 var darkify_is_this_admin_panel = "<?php echo esc_attr(is_admin() ? "1" : "0"); ?>";
175 var darkify_enable_default_dark_mode = "<?php echo esc_attr($enable_default_dark_mode); ?>";
176 var darkify_enable_os_aware = "<?php echo esc_attr($enable_os_aware); ?>";
177 var darkify_enable_keyboard_shortcut = "<?php echo esc_attr($enable_keyboard_shortcut); ?>";
178 var darkify_enable_time_based_dark = "<?php echo esc_attr($enable_time_based_dark); ?>";
179 var darkify_time_based_dark_start = "<?php echo esc_attr($time_based_dark_start ? $time_based_dark_start : ""); ?>";
180 var darkify_time_based_dark_stop = "<?php echo esc_attr($time_based_dark_stop ? $time_based_dark_stop : ""); ?>";
181 var darkify_enable_switch_attention = "<?php echo esc_attr($enable_switch_attention); ?>";
182 var darkify_switch_attention_effect = "<?php echo esc_attr($switch_attention_effect); ?>";
183 var darkify_alternative_dark_mode_switch = "<?php echo esc_attr($alternative_dark_mode_switcher); ?>";
184 var darkify_enable_low_image_brightness = "<?php echo esc_attr($enable_low_image_brightness); ?>";
185 var darkify_image_brightness_to = "<?php echo esc_attr($low_image_brightness_label); ?>";
186 var darkify_enable_image_grayscale = "<?php echo esc_attr($enable_image_grayscale); ?>";
187 var darkify_image_grayscale_to = "<?php echo esc_attr($image_grayscale_label); ?>";
188 var darkify_enable_bg_image_darken = "<?php echo esc_attr($enable_low_image_darken); ?>";
189 var darkify_bg_image_darken_to = "<?php echo esc_attr($low_image_darken_label); ?>";
190 var darkify_enable_invert_inline_svg = "<?php echo esc_attr($enable_invert_inline_svg); ?>";
191 var darkify_enable_low_video_brightness = "<?php echo esc_attr($enable_low_video_brightness); ?>";
192 var darkify_video_brightness_to = "<?php echo esc_attr($low_video_brightness_label); ?>";
193 var darkify_enable_video_grayscale = "<?php echo esc_attr($enable_video_grayscale); ?>";
194 var darkify_video_grayscale_to = "<?php echo esc_attr($video_grayscale_label); ?>";
195
196 var darkify_disallowed_elements = "<?php echo esc_attr($this->utils->generateDisallowedElementsStr($options, $this->external_support)); ?>";
197 var darkify_allowed_btn_class = <?php echo json_encode($this->utils->addButtonClassByDarkify($options)); ?>;
198 </script>
199 <?php
200 $output = ob_get_clean();
201 $tags_allowed_in_output = array(
202 'style' => array('type' => array(), 'class' => array()),
203 'script' => array('type' => array(), 'class' => array())
204 );
205 echo wp_kses($this->utils->minify_string($output), $tags_allowed_in_output);
206