PluginProbe
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) / 1.3.0
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) v1.3.0
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.3.0, at src/Frontend/Templates/header_script.php

223 lines 20.6 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 use ThemeAtelier\Darkify\Helpers\Helpers;
5
6 ob_start();
7 $options = get_option('darkify_pro');
8 $enable_default_dark_mode = isset($options['enable_default_dark_mode']) ? $options['enable_default_dark_mode'] :'';
9 $enable_scrollbar_dark = isset($options["enable_scrollbar_dark"]) ? $options["enable_scrollbar_dark"] :'';
10 $enable_os_aware = isset($options['enable_os_aware']) ? $options['enable_os_aware'] : "";
11 $enable_keyboard_shortcut = isset($options['enable_keyboard_shortcut']) ? $options['enable_keyboard_shortcut'] : "";
12 $enable_switch_dragging = isset($options['enable_switch_dragging']) ? $options['enable_switch_dragging'] : "";
13 $disallowed_elements = isset($options['disallowed_elements']) ? $options['disallowed_elements'] : "";
14 $disallowed_elements_force_to_correct = isset($options['disallowed_elements_force_to_correct']) ? $options['disallowed_elements_force_to_correct'] : "";
15 $allowed_elements_force_to_correct = isset($options['allowed_elements_force_to_correct']) ? $options['allowed_elements_force_to_correct'] : "";
16 $allowed_elements = isset($options['allowed_elements']) ? $options['allowed_elements'] : "";
17 $enable_invert_inline_svg = isset($options['enable_invert_inline_svg']) ? $options['enable_invert_inline_svg'] : "";
18 $alternative_dark_mode_switcher = isset($options['alternative_dark_mode_switcher']) ? $options['alternative_dark_mode_switcher'] : "";
19 $enable_time = isset($options['enable_time']) ? $options['enable_time'] : "";
20 $enable_time_based_dark = isset($enable_time['enable_time_based_dark']) ? $enable_time['enable_time_based_dark'] : "";
21 $time_based_dark_start = isset($enable_time['time_based_dark_start']['from']) ? $enable_time['time_based_dark_start']['from'] : "";
22 $time_based_dark_stop = isset($enable_time['time_based_dark_start']['to']) ? $enable_time['time_based_dark_start']['to'] : "";
23 $grayscale = isset($options['brightness']) ? $options['brightness'] : "";
24 $enable_low_image_brightness = isset($grayscale['enable_low_image_brightness']) ? $grayscale['enable_low_image_brightness'] : "";
25 $low_image_brightness_label = isset($grayscale['low_image_brightness_label']) ? $grayscale['low_image_brightness_label'] : "";
26 $disallowed_low_brightness_images = isset($grayscale['disallowed_low_brightness_images']) ? $grayscale['disallowed_low_brightness_images'] : "[]";
27 $grayscale = isset($options['grayscale']) ? $options['grayscale'] : "";
28 $enable_image_grayscale = isset($grayscale['enable_image_grayscale']) ? $grayscale['enable_image_grayscale'] : "";
29 $image_grayscale_label = isset($grayscale['image_grayscale_label']) ? $grayscale['image_grayscale_label'] : "";
30 $disallowed_low_grayscale_images = isset($grayscale['disallowed_low_grayscale_images']) ? $grayscale['disallowed_low_grayscale_images'] : "";
31 $darken_background = isset($options['darken_background']);
32 $enable_low_image_darken = isset($darken_background['enable_low_image_darken']) ? $darken_background['enable_low_image_darken'] : "";
33 $low_image_darken_label = isset($darken_background['low_image_darken_label']) ? $darken_background['low_image_darken_label'] : "";
34 $video_brightness = isset($options['video_brightness']) ? $options['video_brightness'] : "";
35 $enable_low_video_brightness = isset($video_brightness['enable_low_video_brightness']) ? $video_brightness['enable_low_video_brightness'] : "";
36 $low_video_brightness_label = isset($video_brightness['low_video_brightness_label']) ? $video_brightness['low_video_brightness_label'] : "";
37 $video_grayscale = isset($options['video_grayscale']);
38 $enable_video_grayscale = isset($video_grayscale['enable_video_grayscale']) ? $video_grayscale['enable_video_grayscale'] : "";
39 $video_grayscale_label = isset($video_grayscale['video_grayscale_label']) ? $video_grayscale['video_grayscale_label'] : "";
40 $invert = isset($options['invert']) ? $options['invert'] : "";
41 $enable_invert_images = isset($invert['enable_invert_images']) ? $invert['enable_invert_images'] : "";
42 $invert_images_allowed_urls = isset($invert['invert_images_allowed_urls']) ? $invert['invert_images_allowed_urls'] : "[]";
43 if ($invert_images_allowed_urls !== "") {
44 $invert_images_allowed_urls_explode = explode(',', $invert_images_allowed_urls);
45 $invert_images_allowed_urls_arr = json_encode($invert_images_allowed_urls_explode);
46 }
47
48 $normal_image_replacements = isset($options["image_replacements"][0]["normal_image"]) ? $options["image_replacements"][0]["normal_image"] : [];
49 $dark_image_replacements = isset($options["image_replacements"][0]["dark_image"]) ? $options["image_replacements"][0]["dark_image"] : [];
50 if ($normal_image_replacements || $dark_image_replacements) {
51 $image_replacements = json_encode($options["image_replacements"]);
52 } else {
53 $image_replacements = "[]";
54 }
55
56 $normal_video_replacements = isset($options["video_replacements"][0]["normal_video"]) ? $options["video_replacements"][0]["normal_video"] : [];
57 $dark_video_replacements = isset($options["video_replacements"][0]["dark_video"]) ? $options["video_replacements"][0]["dark_video"] : [];
58 if ($normal_video_replacements || $dark_video_replacements) {
59 $video_replacements = json_encode($options["video_replacements"]);
60 } else {
61 $video_replacements = "[]";
62 }
63 ?>
64
65 <?php if (!is_admin()) { ?>
66 <style type="text/css" class="darkify_inline_css">
67 :root {
68 <?php if ($options["color_pallets"] == 'set1') : ?>--darkify_dark_mode_bg: <?php echo esc_attr($options["dark_mode_color_set1"]['background']); ?>;
69 --darkify_dark_mode_secondary_bg: <?php echo esc_attr($options["dark_mode_color_set1"]['secondary_background']); ?>;
70 --darkify_dark_mode_text_color: <?php echo esc_attr($options["dark_mode_link_color_set1"]['text']); ?>;
71 --darkify_dark_mode_link_color: <?php echo esc_attr($options["dark_mode_link_color_set1"]['color']); ?>;
72 --darkify_dark_mode_link_hover_color: <?php echo esc_attr($options["dark_mode_link_color_set1"]['hover']); ?>;
73 --darkify_dark_mode_input_bg: <?php echo esc_attr($options["dark_mode_input_color_set1"]['background']); ?>;
74 --darkify_dark_mode_input_text_color: <?php echo esc_attr($options["dark_mode_input_color_set1"]['color']); ?>;
75 --darkify_dark_mode_input_placeholder_color: <?php echo esc_attr($options["dark_mode_input_color_set1"]['placeholder']); ?>;
76 --darkify_dark_mode_border_color: <?php echo esc_attr($options["dark_mode_border_color_set1"]); ?>;
77 --darkify_dark_mode_btn_text_color: <?php echo esc_attr($options["dark_mode_btn_color_set1"]['color']); ?>;
78 --darkify_dark_mode_btn_bg: <?php echo esc_attr($options["dark_mode_btn_color_set1"]['background']); ?>;
79 <?php elseif ($options["color_pallets"] == 'set2') : ?>--darkify_dark_mode_bg: <?php echo esc_attr($options["dark_mode_color_set2"]['background']); ?>;
80 --darkify_dark_mode_secondary_bg: <?php echo esc_attr($options["dark_mode_color_set2"]['secondary_background']); ?>;
81 --darkify_dark_mode_text_color: <?php echo esc_attr($options["dark_mode_link_color_set2"]['text']); ?>;
82 --darkify_dark_mode_link_color: <?php echo esc_attr($options["dark_mode_link_color_set2"]['color']); ?>;
83 --darkify_dark_mode_link_hover_color: <?php echo esc_attr($options["dark_mode_link_color_set2"]['hover']); ?>;
84 --darkify_dark_mode_input_bg: <?php echo esc_attr($options["dark_mode_input_color_set2"]['background']); ?>;
85 --darkify_dark_mode_input_text_color: <?php echo esc_attr($options["dark_mode_input_color_set2"]['color']); ?>;
86 --darkify_dark_mode_input_placeholder_color: <?php echo esc_attr($options["dark_mode_input_color_set2"]['placeholder']); ?>;
87 --darkify_dark_mode_border_color: <?php echo esc_attr($options["dark_mode_border_color_set2"]); ?>;
88 --darkify_dark_mode_btn_text_color: <?php echo esc_attr($options["dark_mode_btn_color_set2"]['color']); ?>;
89 --darkify_dark_mode_btn_bg: <?php echo esc_attr($options["dark_mode_btn_color_set2"]['background']); ?>;
90 <?php elseif ($options["color_pallets"] == 'set4') : ?>--darkify_dark_mode_bg: <?php echo esc_attr($options["dark_mode_color_set4"]['background']); ?>;
91 --darkify_dark_mode_secondary_bg: <?php echo esc_attr($options["dark_mode_color_set4"]['secondary_background']); ?>;
92 --darkify_dark_mode_text_color: <?php echo esc_attr($options["dark_mode_link_color_set4"]['text']); ?>;
93 --darkify_dark_mode_link_color: <?php echo esc_attr($options["dark_mode_link_color_set4"]['color']); ?>;
94 --darkify_dark_mode_link_hover_color: <?php echo esc_attr($options["dark_mode_link_color_set4"]['hover']); ?>;
95 --darkify_dark_mode_input_bg: <?php echo esc_attr($options["dark_mode_input_color_set4"]['background']); ?>;
96 --darkify_dark_mode_input_text_color: <?php echo esc_attr($options["dark_mode_input_color_set4"]['color']); ?>;
97 --darkify_dark_mode_input_placeholder_color: <?php echo esc_attr($options["dark_mode_input_color_set4"]['placeholder']); ?>;
98 --darkify_dark_mode_border_color: <?php echo esc_attr($options["dark_mode_border_color_set4"]); ?>;
99 --darkify_dark_mode_btn_text_color: <?php echo esc_attr($options["dark_mode_btn_color_set4"]['color']); ?>;
100 --darkify_dark_mode_btn_bg: <?php echo esc_attr($options["dark_mode_btn_color_set4"]['background']); ?>;
101 <?php elseif ($options["color_pallets"] == 'set5') : ?>--darkify_dark_mode_bg: <?php echo esc_attr($options["dark_mode_color_set5"]['background']); ?>;
102 --darkify_dark_mode_secondary_bg: <?php echo esc_attr($options["dark_mode_color_set5"]['secondary_background']); ?>;
103 --darkify_dark_mode_text_color: <?php echo esc_attr($options["dark_mode_link_color_set5"]['text']); ?>;
104 --darkify_dark_mode_link_color: <?php echo esc_attr($options["dark_mode_link_color_set5"]['color']); ?>;
105 --darkify_dark_mode_link_hover_color: <?php echo esc_attr($options["dark_mode_link_color_set5"]['hover']); ?>;
106 --darkify_dark_mode_input_bg: <?php echo esc_attr($options["dark_mode_input_color_set5"]['background']); ?>;
107 --darkify_dark_mode_input_text_color: <?php echo esc_attr($options["dark_mode_input_color_set5"]['color']); ?>;
108 --darkify_dark_mode_input_placeholder_color: <?php echo esc_attr($options["dark_mode_input_color_set5"]['placeholder']); ?>;
109 --darkify_dark_mode_border_color: <?php echo esc_attr($options["dark_mode_border_color_set5"]); ?>;
110 --darkify_dark_mode_btn_text_color: <?php echo esc_attr($options["dark_mode_btn_color_set5"]['color']); ?>;
111 --darkify_dark_mode_btn_bg: <?php echo esc_attr($options["dark_mode_btn_color_set5"]['background']); ?>;
112 <?php elseif ($options["color_pallets"] == 'set6') : ?>--darkify_dark_mode_bg: <?php echo esc_attr($options["dark_mode_color_set6"]['background']); ?>;
113 --darkify_dark_mode_secondary_bg: <?php echo esc_attr($options["dark_mode_color_set6"]['secondary_background']); ?>;
114 --darkify_dark_mode_text_color: <?php echo esc_attr($options["dark_mode_link_color_set6"]['text']); ?>;
115 --darkify_dark_mode_link_color: <?php echo esc_attr($options["dark_mode_link_color_set6"]['color']); ?>;
116 --darkify_dark_mode_link_hover_color: <?php echo esc_attr($options["dark_mode_link_color_set6"]['hover']); ?>;
117 --darkify_dark_mode_input_bg: <?php echo esc_attr($options["dark_mode_input_color_set6"]['background']); ?>;
118 --darkify_dark_mode_input_text_color: <?php echo esc_attr($options["dark_mode_input_color_set6"]['color']); ?>;
119 --darkify_dark_mode_input_placeholder_color: <?php echo esc_attr($options["dark_mode_input_color_set6"]['placeholder']); ?>;
120 --darkify_dark_mode_border_color: <?php echo esc_attr($options["dark_mode_border_color_set6"]); ?>;
121 --darkify_dark_mode_btn_text_color: <?php echo esc_attr($options["dark_mode_btn_color_set6"]['color']); ?>;
122 --darkify_dark_mode_btn_bg: <?php echo esc_attr($options["dark_mode_btn_color_set6"]['background']); ?>;
123 <?php elseif ($options["color_pallets"] == 'set9') : ?>--darkify_dark_mode_bg: <?php echo esc_attr($options["dark_mode_color_set9"]['background']); ?>;
124 --darkify_dark_mode_secondary_bg: <?php echo esc_attr($options["dark_mode_color_set9"]['secondary_background']); ?>;
125 --darkify_dark_mode_text_color: <?php echo esc_attr($options["dark_mode_link_color_set9"]['text']); ?>;
126 --darkify_dark_mode_link_color: <?php echo esc_attr($options["dark_mode_link_color_set9"]['color']); ?>;
127 --darkify_dark_mode_link_hover_color: <?php echo esc_attr($options["dark_mode_link_color_set9"]['hover']); ?>;
128 --darkify_dark_mode_input_bg: <?php echo esc_attr($options["dark_mode_input_color_set9"]['background']); ?>;
129 --darkify_dark_mode_input_text_color: <?php echo esc_attr($options["dark_mode_input_color_set9"]['color']); ?>;
130 --darkify_dark_mode_input_placeholder_color: <?php echo esc_attr($options["dark_mode_input_color_set9"]['placeholder']); ?>;
131 --darkify_dark_mode_border_color: <?php echo esc_attr($options["dark_mode_border_color_set9"]); ?>;
132 --darkify_dark_mode_btn_text_color: <?php echo esc_attr($options["dark_mode_btn_color_set9"]['color']); ?>;
133 --darkify_dark_mode_btn_bg: <?php echo esc_attr($options["dark_mode_btn_color_set9"]['background']); ?>;
134 <?php elseif ($options["color_pallets"] == 'set10') : ?>--darkify_dark_mode_bg: <?php echo esc_attr($options["dark_mode_color_set10"]['background']); ?>;
135 --darkify_dark_mode_secondary_bg: <?php echo esc_attr($options["dark_mode_color_set10"]['secondary_background']); ?>;
136 --darkify_dark_mode_text_color: <?php echo esc_attr($options["dark_mode_link_color_set10"]['text']); ?>;
137 --darkify_dark_mode_link_color: <?php echo esc_attr($options["dark_mode_link_color_set10"]['color']); ?>;
138 --darkify_dark_mode_link_hover_color: <?php echo esc_attr($options["dark_mode_link_color_set10"]['hover']); ?>;
139 --darkify_dark_mode_input_bg: <?php echo esc_attr($options["dark_mode_input_color_set10"]['background']); ?>;
140 --darkify_dark_mode_input_text_color: <?php echo esc_attr($options["dark_mode_input_color_set10"]['color']); ?>;
141 --darkify_dark_mode_input_placeholder_color: <?php echo esc_attr($options["dark_mode_input_color_set10"]['placeholder']); ?>;
142 --darkify_dark_mode_border_color: <?php echo esc_attr($options["dark_mode_border_color_set10"]); ?>;
143 --darkify_dark_mode_btn_text_color: <?php echo esc_attr($options["dark_mode_btn_color_set10"]['color']); ?>;
144 --darkify_dark_mode_btn_bg: <?php echo esc_attr($options["dark_mode_btn_color_set10"]['background']); ?>;
145 <?php elseif ($options["color_pallets"] == 'set11') : ?>--darkify_dark_mode_bg: <?php echo esc_attr($options["dark_mode_color_set11"]['background']); ?>;
146 --darkify_dark_mode_secondary_bg: <?php echo esc_attr($options["dark_mode_color_set11"]['secondary_background']); ?>;
147 --darkify_dark_mode_text_color: <?php echo esc_attr($options["dark_mode_link_color_set11"]['text']); ?>;
148 --darkify_dark_mode_link_color: <?php echo esc_attr($options["dark_mode_link_color_set11"]['color']); ?>;
149 --darkify_dark_mode_link_hover_color: <?php echo esc_attr($options["dark_mode_link_color_set11"]['hover']); ?>;
150 --darkify_dark_mode_input_bg: <?php echo esc_attr($options["dark_mode_input_color_set11"]['background']); ?>;
151 --darkify_dark_mode_input_text_color: <?php echo esc_attr($options["dark_mode_input_color_set11"]['color']); ?>;
152 --darkify_dark_mode_input_placeholder_color: <?php echo esc_attr($options["dark_mode_input_color_set11"]['placeholder']); ?>;
153 --darkify_dark_mode_border_color: <?php echo esc_attr($options["dark_mode_border_color_set11"]); ?>;
154 --darkify_dark_mode_btn_text_color: <?php echo esc_attr($options["dark_mode_btn_color_set11"]['color']); ?>;
155 --darkify_dark_mode_btn_bg: <?php echo esc_attr($options["dark_mode_btn_color_set11"]['background']); ?>;
156 <?php endif; ?>
157 }
158 </style>
159 <?php } else { ?>
160 <style type="text/css" class="darkify_inline_css">
161 :root {
162 --darkify_dark_mode_bg: #181a1b;
163 --darkify_dark_mode_secondary_bg: #202324;
164 --darkify_dark_mode_text_color: #c8c4bd;
165 --darkify_dark_mode_link_color: #6aafe2;
166 --darkify_dark_mode_link_hover_color: #4f94c3;
167 --darkify_dark_mode_input_bg: #2D2D2D;
168 --darkify_dark_mode_input_text_color: #BEBEBE;
169 --darkify_dark_mode_input_placeholder_color: #989898;
170 --darkify_dark_mode_border_color: #4A4A4A;
171 --darkify_dark_mode_btn_bg: #2D2D2D;
172 --darkify_dark_mode_btn_text_color: #BEBEBE;
173 }
174 </style>
175 <?php } ?>
176
177 <?php if ($enable_scrollbar_dark) { ?>
178 <?php include_once Helpers::darkify_locate_template('views/scrollbar.php') ?>
179 <?php } ?>
180
181 <script type="text/javascript" class="darkify_inline_js">
182 var darkify_switch_unique_id = "<?php echo esc_attr($this->unique_id); ?>";
183 var darkify_is_this_admin_panel = "<?php echo esc_attr(is_admin() ? "1" : "0"); ?>";
184 var darkify_enable_default_dark_mode = "<?php echo esc_attr($enable_default_dark_mode); ?>";
185 var darkify_enable_os_aware = "<?php echo esc_attr($enable_os_aware); ?>";
186 var darkify_enable_keyboard_shortcut = "<?php echo esc_attr($enable_keyboard_shortcut); ?>";
187 var darkify_enable_time_based_dark = "<?php echo esc_attr($enable_time_based_dark); ?>";
188 var darkify_time_based_dark_start = "<?php echo esc_attr($time_based_dark_start ? $time_based_dark_start : "19:00"); ?>";
189 var darkify_time_based_dark_stop = "<?php echo esc_attr($time_based_dark_stop ? $time_based_dark_stop : "07:00"); ?>";
190 var darkify_enable_switch_dragging = "<?php echo esc_attr($enable_switch_dragging); ?>";
191 var darkify_alternative_dark_mode_switch = "<?php echo esc_attr($alternative_dark_mode_switcher); ?>";
192 var darkify_enable_low_image_brightness = "<?php echo esc_attr($enable_low_image_brightness); ?>";
193 var darkify_image_brightness_to = "<?php echo esc_attr($low_image_brightness_label); ?>";
194 var darkify_disallowed_low_brightness_images = "<?php echo esc_attr($disallowed_low_brightness_images); ?>";
195 var darkify_enable_image_grayscale = "<?php echo esc_attr($enable_image_grayscale); ?>";
196 var darkify_image_grayscale_to = "<?php echo esc_attr($image_grayscale_label); ?>";
197 var darkify_disallowed_grayscale_images = "<?php echo esc_attr($disallowed_low_grayscale_images); ?>";
198 var darkify_enable_bg_image_darken = "<?php echo esc_attr($enable_low_image_darken); ?>";
199 var darkify_bg_image_darken_to = "<?php echo esc_attr($low_image_darken_label); ?>";
200 var darkify_enable_invert_inline_svg = "<?php echo esc_attr($enable_invert_inline_svg); ?>";
201 var darkify_enable_invert_images = "<?php echo esc_attr($enable_invert_images); ?>";
202 var darkify_invert_images_allowed_urls = "<?php echo esc_attr($invert_images_allowed_urls ? $invert_images_allowed_urls_arr : "[]"); ?>";
203 var darkify_image_replacements = "<?php echo esc_attr($image_replacements) ?>";
204 var darkify_enable_low_video_brightness = "<?php echo esc_attr($enable_low_video_brightness); ?>";
205 var darkify_video_brightness_to = "<?php echo esc_attr($low_video_brightness_label); ?>";
206 var darkify_enable_video_grayscale = "<?php echo esc_attr($enable_video_grayscale); ?>";
207 var darkify_video_grayscale_to = "<?php echo esc_attr($video_grayscale_label); ?>";
208 var darkify_video_replacements = "<?PHP echo esc_attr($video_replacements); ?>";
209 var darkify_allowed_elements = "<?php echo esc_attr(DarkifyUtils::generateAllowedElementsStr($options)); ?>";
210 var darkify_allowed_elements_raw = "<?php echo esc_attr($allowed_elements); ?>";
211 var darkify_allowed_elements_force_to_correct = "<?php echo esc_attr($allowed_elements_force_to_correct); ?>";
212 var darkify_disallowed_elements = "<?php echo esc_attr(DarkifyUtils::generateDisallowedElementsStr($options, $this->external_support)); ?>";
213 var darkify_disallowed_elements_raw = "<?php echo esc_attr($disallowed_elements); ?>";
214 var darkify_disallowed_elements_force_to_correct = "<?php echo esc_attr($disallowed_elements_force_to_correct); ?>";
215 </script>
216 <?php
217 $output = ob_get_clean();
218 $tags_allowed_in_output = array(
219 'style' => array('type' => array(), 'class' => array()),
220 'script' => array('type' => array(), 'class' => array())
221 );
222 echo wp_kses($this->utils->minify_string($output), $tags_allowed_in_output);
223 ?>