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 / footer_script.php

footer_script.php in Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) 1.3.0, at src/Frontend/Templates/footer_script.php

80 lines 4.1 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 $options = get_option('darkify_pro');
7 $hide_on_desktop = isset($options["hide_on_desktop"]) ? $options["hide_on_desktop"] : '';
8 $hide_on_mobile = isset($options["hide_on_mobile"]) ? $options["hide_on_mobile"] : '';
9 $enable_admin_panel_dark_mode = isset($options["enable_admin_panel_dark_mode"]) ? $options["enable_admin_panel_dark_mode"] : '';
10 $hide_dark_mode_on_mobile = isset($hide_on_mobile["hide_dark_mode_on_mobile"]) ? $hide_on_mobile["hide_dark_mode_on_mobile"] : 0;
11 $type_of_hide_by = isset($hide_on_mobile["type_of_hide_by"]) ? $hide_on_mobile["type_of_hide_by"] : 0;
12 $normal_custom_css = isset($hide_on_mobile["normal_custom_css"]) ? $hide_on_mobile["normal_custom_css"] : "";
13 $disallowed_elements_force_to_correct = isset($hide_on_mobile["disallowed_elements_force_to_correct"]) ? $hide_on_mobile["disallowed_elements_force_to_correct"] : "";
14 $custom_css = isset($hide_on_mobile["custom_css"]) ? $hide_on_mobile["custom_css"] : "";
15
16 if (!is_admin()) {
17 if ($options["enable_dark_mode_switch"]) {
18 if (!$this->utils->is_hidden_by_user_agent($hide_on_desktop, $hide_dark_mode_on_mobile, $type_of_hide_by)) {
19 include_once Helpers::darkify_locate_template('views/switch.php');
20 }
21 }
22 }
23
24 ?>
25
26 <style type="text/css" class="darkify_inline_css">
27 <?php echo esc_attr(DarkifyUtils::parseAndProcessNormalCustomCSS($normal_custom_css)); ?>
28 </style>
29 <style type="text/css" class="darkify_inline_css">
30 <?php echo esc_attr(DarkifyUtils::parseAndProcessCustomCSS($custom_css, $disallowed_elements_force_to_correct)); ?>
31 </style>
32
33
34
35 <?php if (!is_admin()) { ?>
36 <script type="text/javascript" class="darkify_inline_js">
37 document.addEventListener("DOMContentLoaded", function(event) {
38 darkify_init_draggable_floating_switch();
39 darkify_init_alternative_dark_mode_switch();
40 });
41 </script>
42 <?php } ?>
43
44 <?php if (is_admin()) { ?>
45 <?php /* Check if block editor is on, then add the dark mode button there */ ?>
46 <?php if ($enable_admin_panel_dark_mode) { ?>
47 <?php if (class_exists('WP_Block_Type_Registry')) { ?>
48 <?php if (get_current_screen() && 'post' === get_current_screen()->base && ('post' === get_current_screen()->post_type || 'page' === get_current_screen()->post_type)) { ?>
49 <script type="text/javascript" class="darkify_inline_js">
50 wp.domReady(function() {
51 const observer = new MutationObserver(function(mutations) {
52 mutations.forEach(function(mutation) {
53 if (mutation.addedNodes && mutation.addedNodes.length) {
54 for (let i = 0; i < mutation.addedNodes.length; i++) {
55 const node = mutation.addedNodes[i];
56 if (node.classList && node.classList.contains('edit-post-header-toolbar')) {
57 const button = document.createElement('button');
58 button.className = 'darkify_block_editor_switch darkify_ignore';
59 button.innerHTML = '<div class="icon"></div>';
60 button.onclick = function() {
61 darkify_switch_trigger();
62 };
63 node.appendChild(button);
64 observer.disconnect();
65 return;
66 }
67 }
68 }
69 });
70 });
71 observer.observe(document.body, {
72 childList: true,
73 subtree: true
74 });
75 });
76 </script>
77 <?php } ?>
78 <?php } ?>
79 <?php } ?>
80 <?php } ?>