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

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

- Page: https://pluginprobe.com/plugins/darkify/1.5.0/code/src/Frontend/Templates/footer_script.php
- Raw: https://pluginprobe.com/plugins/darkify/1.5.0/raw/src/Frontend/Templates/footer_script.php
- Modified: 2026-04-20T07:46:20+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.0/code/src/Frontend/Templates/footer_script.php#L10-L20`.

```php
<?php

use ThemeAtelier\Darkify\Includes\DarkifyUtils;

// don't call the file directly.
if (!defined('ABSPATH')) {
    exit;
}

$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"] : '';
$block_editor_dark_mode = isset($options['block_editor_dark_mode']) ? $options['block_editor_dark_mode'] : false;
$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"] : "";
$admin_custom_css = isset($options['admin_custom_css']) ? $options['admin_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 wp_strip_all_tags(DarkifyUtils::parseAndProcessNormalCustomCSS($normal_custom_css)); ?>
</style>
<style type="text/css" class="darkify_inline_css">
    <?php echo wp_strip_all_tags(DarkifyUtils::parseAndProcessCustomCSS($custom_css, false)); ?>
</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() && $block_editor_dark_mode) {
?><style type="text/css" class="darkify_inline_css">
        <?php echo esc_html(DarkifyUtils::parseAndProcessCustomCSS($admin_custom_css, 'yes')); ?>
    </style>
    <?php
    /* 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">
                    (function checkForWP() {
                        if (typeof wp === 'undefined' || typeof wp.domReady === 'undefined') {
                            // Wait and try again (e.g., if Gutenberg scripts haven’t loaded yet)
                            return setTimeout(checkForWP, 200);
                        }

                        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 }
        }
    }
}

```
