# darkify/1.4.0/src/Frontend/Templates/footer_script.php

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

- Page: https://pluginprobe.com/plugins/darkify/1.4.0/code/src/Frontend/Templates/footer_script.php
- Raw: https://pluginprobe.com/plugins/darkify/1.4.0/raw/src/Frontend/Templates/footer_script.php
- Modified: 2025-05-15T13:43:26+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.4.0/code/src/Frontend/Templates/footer_script.php#L10-L20`.

```php
<?php

use ThemeAtelier\Darkify\Helpers\DarkifyUtils;

$options = get_option('darkify');
$enable_dark_mode_switch = isset($options["enable_dark_mode_switch"]) ? $options["enable_dark_mode_switch"] : true;
$hide_on_desktop = isset($options["hide_on_desktop"]) ? $options["hide_on_desktop"] : '';
$hide_on_mobile = isset($options["hide_on_mobile"]) ? $options["hide_on_mobile"] : '';
$enable_admin_panel_dark_mode = isset($options["enable_admin_panel_dark_mode"]) ? $options["enable_admin_panel_dark_mode"] : '';
$hide_dark_mode_on_mobile = isset($hide_on_mobile["hide_dark_mode_on_mobile"]) ? $hide_on_mobile["hide_dark_mode_on_mobile"] : 0;
$type_of_hide_by = isset($hide_on_mobile["type_of_hide_by"]) ? $hide_on_mobile["type_of_hide_by"] : 0;

$normal_custom_css = isset($options["normal_custom_css"]) ? $options["normal_custom_css"] : "";
$custom_css = isset($options["custom_css"]) ? $options["custom_css"] : "";

if (!is_admin()) {
    if ($enable_dark_mode_switch) {
        if (!$this->utils->is_hidden_by_user_agent($hide_on_desktop, $hide_dark_mode_on_mobile, $type_of_hide_by)) {
            include_once DarkifyUtils::darkify_locate_template('views/switch.php');
        }
    }
}
?>

<style type="text/css" class="darkify_inline_css">
    <?php echo esc_attr(DarkifyUtils::parseAndProcessNormalCustomCSS($normal_custom_css)); ?>
</style>
<style type="text/css" class="darkify_inline_css">
    <?php echo esc_attr(DarkifyUtils::parseAndProcessCustomCSS($custom_css)); ?>
</style>

<?php if (!is_admin()) { ?>
    <script type="text/javascript" class="darkify_inline_js">
        document.addEventListener("DOMContentLoaded", function(event) {
            darkify_init_alternative_dark_mode_switch();
        });
    </script>
    <?php }

if (is_admin()) {
    /* Check if block editor is on, then add the dark mode button there */
    if ($enable_admin_panel_dark_mode) {
        if (class_exists('WP_Block_Type_Registry')) {

            if (get_current_screen() && 'post' === get_current_screen()->base && ('post' === get_current_screen()->post_type || 'page' === get_current_screen()->post_type)) { ?>
                <script type="text/javascript" class="darkify_inline_js">
                    wp.domReady(function() {
                        const observer = new MutationObserver(function(mutations) {
                            mutations.forEach(function(mutation) {
                                if (mutation.addedNodes && mutation.addedNodes.length) {
                                    for (let i = 0; i < mutation.addedNodes.length; i++) {
                                        const node = mutation.addedNodes[i];
                                        if (node.classList && (node.classList.contains('edit-post-header-toolbar') || node.classList.contains('interface-pinned-items'))) {
                                            const button = document.createElement('button');
                                            button.className = 'darkify_block_editor_switch darkify_ignore';
                                            button.innerHTML = '<div class="icon"></div>';
                                            button.onclick = function() {
                                                darkify_switch_trigger();
                                            };
                                            node.appendChild(button);
                                            observer.disconnect();
                                            return;
                                        }
                                    }
                                }
                            });
                        });
                        observer.observe(document.body, {
                            childList: true,
                            subtree: true
                        });
                    });
                </script>
<?php }
        }
    }
}

```
