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