| @@ -23,8 +23,19 @@ | ||
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public function darkify_shortcode_parser($atts, $content = null) |
| 26 | 26 | { |
| 27 | + // With Frontend Dark Mode off, client_main.css/.js are never | |
| 28 | + // enqueued on the front end, so rendering the switch markup anyway | |
| 29 | + // leaves an unstyled toggle behind that does nothing when clicked. | |
| 30 | + // Gate every switch entry point here: the Gutenberg block and the | |
| 31 | + // Elementor widget both render through this shortcode. The floating | |
| 32 | + // switch, menu switch and inline scripts are already gated in | |
| 33 | + // Frontend.php. | |
| 34 | + if (! $this->base_client->darkify_is_dark_mode_allowed()) { | |
| 35 | + return ''; | |
| 36 | + } | |
| 37 | + | |
| 27 | 38 | $options = get_option('darkify'); |
| 28 | 39 | |
| 29 | 40 | // Background |
| 30 | 41 | $switch_background = isset($options['switch_background']) ? $options['switch_background'] : []; |
| @@ -89,9 +100,11 @@ | ||
| 89 | 100 | } elseif ($switcher_number === '5') { |
| 90 | 101 | $switcher_number = 'orbit'; |
| 91 | 102 | } |
| 92 | 103 | $switch_size = $atts['switch_size'] / 100; |
| 93 | - echo Darkify::switcher_wrapper('shortcode', $unique_id, $switcher_number, $switch_size); | |
| 104 | + // switcher_wrapper() escapes each dynamic value internally, so its | |
| 105 | + // returned markup is safe to print as-is. | |
| 106 | + echo Darkify::switcher_wrapper('shortcode', $unique_id, $switcher_number, $switch_size); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 94 | 107 | return ob_get_clean(); |
| 95 | 108 | } |
| 96 | 109 | } |
| 97 | 110 | } |