PluginProbe
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) / 1.4.0
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) v1.4.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.4.0, at src/Frontend/Templates/footer_script.php

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