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

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

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