# darkify/1.5.2/src/Frontend/Templates/header_script.php

Darkify – Dark Mode &amp; Night Mode for Website &amp; Admin (Dark Theme Included), version 1.5.2. 201 lines.

- Page: https://pluginprobe.com/plugins/darkify/1.5.2/code/src/Frontend/Templates/header_script.php
- Raw: https://pluginprobe.com/plugins/darkify/1.5.2/raw/src/Frontend/Templates/header_script.php
- Modified: 2026-05-05T12:34:32+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/darkify/1.5.2/code/src/Frontend/Templates/header_script.php#L10-L20`.

```php
<?php

use ThemeAtelier\Darkify\Includes\DarkifyUtils;
// don't call the file directly.
if (!defined('ABSPATH')) {
    exit;
}

ob_start();
$options = get_option('darkify');
$enable_default_dark_mode   = isset($options['enable_default_dark_mode']) ? $options['enable_default_dark_mode'] : '';
$enable_os_aware = isset($options['enable_os_aware']) ? $options['enable_os_aware'] : true;
$enable_keyboard_shortcut = isset($options['enable_keyboard_shortcut']) ? $options['enable_keyboard_shortcut'] : true;
$enable_time = isset($options['enable_time']) ? $options['enable_time'] : "";
$enable_time_based_dark     = isset($enable_time['enable_time_based_dark']) ? $enable_time['enable_time_based_dark'] : "";
$enable_time_fields     = isset($enable_time['enable_time_fields']) ? $enable_time['enable_time_fields'] : '';
$time_based_dark_start      = isset($enable_time_fields['time_based_dark_start']) ? $enable_time_fields['time_based_dark_start'] : "";
$time_based_dark_stop       =  isset($enable_time_fields['time_based_dark_end'])  ?  $enable_time_fields['time_based_dark_end'] : "";

// Extras
$enable_scrollbar_dark   = isset($options["enable_scrollbar_dark"]) ? $options["enable_scrollbar_dark"] : true;
$alternative_dark_mode_switcher = isset($options['alternative_dark_mode_switcher']) ? $options['alternative_dark_mode_switcher'] : "";

// Image Control
$brightness =  isset($options['brightness']) ? $options['brightness'] : "";
$enable_low_image_brightness    =  isset($brightness['enable_low_image_brightness']) ? $brightness['enable_low_image_brightness'] : "1";
$low_image_brightness_label     =  isset($brightness['low_image_brightness_label']) ? 100 - $brightness['low_image_brightness_label'] : 100 - "20";

$grayscale      =  isset($options['grayscale']) ? $options['grayscale'] : "";
$enable_image_grayscale =  isset($grayscale['enable_image_grayscale']) ? $grayscale['enable_image_grayscale'] : "";
$image_grayscale_label  =  isset($grayscale['image_grayscale_label']) ? $grayscale['image_grayscale_label'] : "80";

$darken_background  =  isset($options['darken_background']) ? $options['darken_background'] : "";
$enable_low_image_darken    =  isset($darken_background['enable_low_image_darken']) ? $darken_background['enable_low_image_darken'] : "1";
$low_image_darken_label     =  isset($darken_background['low_image_darken_label']) ? $darken_background['low_image_darken_label'] : "60";

$enable_invert_inline_svg = isset($options['enable_invert_inline_svg']) ? $options['enable_invert_inline_svg'] : "";

// Video Control
$video_brightness =  isset($options['video_brightness']) ? $options['video_brightness'] : "";
$enable_low_video_brightness    =  isset($video_brightness['enable_low_video_brightness']) ? $video_brightness['enable_low_video_brightness'] : true;
$low_video_brightness_label     =  isset($video_brightness['low_video_brightness_label']) ? 100 - $video_brightness['low_video_brightness_label'] : 100 - "20";

$video_grayscale =  isset($options['video_grayscale']) ? $options['video_grayscale'] : '';
$enable_video_grayscale     =  isset($video_grayscale['enable_video_grayscale']) ? $video_grayscale['enable_video_grayscale'] : "";
$video_grayscale_label      =  isset($video_grayscale['video_grayscale_label']) ? $video_grayscale['video_grayscale_label']  : "80";


if (!is_admin()) { ?>
    <style type="text/css" class="darkify_inline_css">
        :root {
            <?php
            $dark_mode_color_palettes = [
                'set1' => [
                    'bg' => isset($options["dark_mode_color_set1"]) ? $options["dark_mode_color_set1"]['background'] : '#0F0F0F',
                    'secondary_bg' => isset($options["dark_mode_color_set1"]) ? $options["dark_mode_color_set1"]['secondary_background'] : '#171717',
                    'text_color' => '#BEBEBE',
                    'link_color' => '#E7E7E7',
                    'link_hover_color' => '#BEBEBE',
                    'input_bg' => '#2D2D2D',
                    'input_text_color' => '#BEBEBE',
                    'input_placeholder_color' => '#BEBEBE',
                    'border_color' => '#4A4A4A',
                    'btn_text_color' => '#BEBEBE',
                    'btn_bg' => '#4A4A4A',
                    'btn_text_hover_color' => '#BEBEBE',
                    'btn_hover_bg' => '#2D2D2D',
                ],
                'set3' => [
                    'bg' => isset($options["dark_mode_color_set3"]) ? $options["dark_mode_color_set3"]['background'] : '#211e3c',
                    'secondary_bg' => isset($options["dark_mode_color_set3"]) ? $options["dark_mode_color_set3"]['secondary_background'] : '#302C57',
                    'text_color' => '#B1BBD8',
                    'link_color' => '#8071fb',
                    'link_hover_color' => '#B1BBD8',
                    'input_bg' => '#2A264D',
                    'input_text_color' => '#B1BBD8',
                    'input_placeholder_color' => '#B1BBD8',
                    'border_color' => '#4E478D',
                    'btn_text_color' => '#B1BBD8',
                    'btn_bg' => '#4E478D',
                    'btn_text_hover_color' => '#B1BBD8',
                    'btn_hover_bg' => '#2A264D',
                ],
                'set9' => [
                    'bg' => isset($options["dark_mode_color_set9"]) ? $options["dark_mode_color_set9"]['background'] : '#04261d',
                    'secondary_bg' => isset($options["dark_mode_color_set9"]) ? $options["dark_mode_color_set9"]['secondary_background'] : '#021e16',
                    'text_color' => '#C1D2BB',
                    'link_color' => '#00d29a',
                    'link_hover_color' => '#C1D2BB',
                    'input_bg' => '#073d2f',
                    'input_text_color' => '#C1D2BB',
                    'input_placeholder_color' => '#C1D2BB',
                    'border_color' => '#095541',
                    'btn_text_color' => '#C1D2BB',
                    'btn_bg' => '#095541',
                    'btn_text_hover_color' => '#C1D2BB',
                    'btn_hover_bg' => '#073d2f',
                ],
                'set6' => [
                    'bg' => isset($options["dark_mode_color_set6"]) ? $options["dark_mode_color_set6"]['background'] : '#082032',
                    'secondary_bg' => isset($options["dark_mode_color_set6"]) ? $options["dark_mode_color_set6"]['secondary_background'] : '#061825',
                    'text_color' => '#B5D9F3',
                    'link_color' => '#61bbff',
                    'link_hover_color' => '#B5D9F3',
                    'input_bg' => '#0E3755',
                    'input_text_color' => '#B5D9F3',
                    'input_placeholder_color' => '#B5D9F3',
                    'border_color' => '#144E78',
                    'btn_text_color' => '#B5D9F3',
                    'btn_bg' => '#144E78',
                    'btn_text_hover_color' => '#B5D9F3',
                    'btn_hover_bg' => '#0E3755',
                ],
                'set10' => [
                    'bg' => isset($options["dark_mode_color_set10"]) ? $options["dark_mode_color_set10"]['background'] : '#171004',
                    'secondary_bg' => isset($options["dark_mode_color_set10"]) ? $options["dark_mode_color_set10"]['secondary_background'] : '#211706',
                    'text_color' => '#E0D2BD',
                    'link_color' => '#e09525',
                    'link_hover_color' => '#E0D2BD',
                    'input_bg' => '#372911',
                    'input_text_color' => '#E0D2BD',
                    'input_placeholder_color' => '#E0D2BD',
                    'border_color' => '#5D4010',
                    'btn_text_color' => '#E0D2BD',
                    'btn_bg' => '#5D4010',
                    'btn_text_hover_color' => '#E0D2BD',
                    'btn_hover_bg' => '#372911',
                ],
            ];


            $selected_set_key = isset($options['color_pallets']) ? $options['color_pallets'] : 'set1';
            $selected_set = $dark_mode_color_palettes[$selected_set_key] ?? $dark_mode_color_palettes['set1'];

            // Output as CSS variables
            foreach ($selected_set as $key => $value) {
                echo '--darkify_dark_mode_' . esc_attr($key) . ': ' . esc_attr($value) . ';';
            }
            ?>
        }
    </style>
<?php } else { ?>
    <style type="text/css" class="darkify_inline_css">
        :root {
            --darkify_dark_mode_bg: #181a1b;
            --darkify_dark_mode_secondary_bg: #202324;
            --darkify_dark_mode_text_color: #c8c4bd;
            --darkify_dark_mode_link_color: #6aafe2;
            --darkify_dark_mode_link_hover_color: #4f94c3;
            --darkify_dark_mode_input_bg: #2D2D2D;
            --darkify_dark_mode_input_text_color: #BEBEBE;
            --darkify_dark_mode_input_placeholder_color: #989898;
            --darkify_dark_mode_border_color: #4A4A4A;
            --darkify_dark_mode_btn_bg: #2D2D2D;
            --darkify_dark_mode_btn_text_color: #BEBEBE;
            --darkify_dark_mode_btn_hover_bg: #BEBEBE;
            --darkify_dark_mode_btn_text_hover_color: #2D2D2D;
        }
    </style>
<?php }

if ($enable_scrollbar_dark) {
    $dark_mode_scrollbar_track_bg = '#29292a';
    $dark_mode_scrollbar_thumb_bg = '#52565a';
    include DarkifyUtils::darkify_locate_template('views/scrollbar.php');
}
?>

<script type="text/javascript" class="darkify_inline_js">
    var darkify_switch_unique_id = "<?php echo esc_attr($this->unique_id); ?>";
    var darkify_is_this_admin_panel = "<?php echo esc_attr(is_admin() ? "1" : "0"); ?>";
    var darkify_enable_default_dark_mode = "<?php echo esc_attr($enable_default_dark_mode); ?>";
    var darkify_enable_os_aware = "<?php echo esc_attr($enable_os_aware); ?>";
    var darkify_enable_keyboard_shortcut = "<?php echo esc_attr($enable_keyboard_shortcut); ?>";
    var darkify_enable_time_based_dark = "<?php echo esc_attr($enable_time_based_dark); ?>";
    var darkify_time_based_dark_start = "<?php echo esc_attr($time_based_dark_start ? $time_based_dark_start : ""); ?>";
    var darkify_time_based_dark_stop = "<?php echo esc_attr($time_based_dark_stop ? $time_based_dark_stop : ""); ?>";
    var darkify_alternative_dark_mode_switch = "<?php echo esc_attr($alternative_dark_mode_switcher); ?>";
    var darkify_enable_low_image_brightness = "<?php echo esc_attr($enable_low_image_brightness); ?>";
    var darkify_image_brightness_to = "<?php echo esc_attr($low_image_brightness_label); ?>";
    var darkify_enable_image_grayscale = "<?php echo esc_attr($enable_image_grayscale); ?>";
    var darkify_image_grayscale_to = "<?php echo esc_attr($image_grayscale_label); ?>";
    var darkify_enable_bg_image_darken = "<?php echo esc_attr($enable_low_image_darken); ?>";
    var darkify_bg_image_darken_to = "<?php echo esc_attr($low_image_darken_label); ?>";
    var darkify_enable_invert_inline_svg = "<?php echo esc_attr($enable_invert_inline_svg); ?>";
    var darkify_enable_low_video_brightness = "<?php echo esc_attr($enable_low_video_brightness); ?>";
    var darkify_video_brightness_to = "<?php echo esc_attr($low_video_brightness_label); ?>";
    var darkify_enable_video_grayscale = "<?php echo esc_attr($enable_video_grayscale); ?>";
    var darkify_video_grayscale_to = "<?php echo esc_attr($video_grayscale_label); ?>";

    var darkify_disallowed_elements = "<?php echo esc_attr($this->utils->generateDisallowedElementsStr($options, $this->external_support)); ?>";
    var darkify_allowed_btn_class = <?php echo json_encode($this->utils->addButtonClassByDarkify($options)); ?>;
</script>
<?php
$output = ob_get_clean();
$tags_allowed_in_output = array(
    'style' => array('type' => array(), 'class' => array()),
    'script' => array('type' => array(), 'class' => array())
);
echo wp_kses($this->utils->minify_string($output), $tags_allowed_in_output);

```
