Is it possible to inject my own predefined HTML classes into a complete wordpress theme’s jquery code?


I added a header slider to a wordpress theme. It looks and works great. I want to take it much further. The wordpress theme has a dark mode toggler. When you click on this toggler the whole site changes to black and the colors white. It works for the whole site except the slider. I have seen the function doing in this in the themes functions PHP file and I was wondering if I could inject my slider classes into that function. I already tried but it doesn’t work. The code is written with jquery but I know absolutely nothing about jquery. Is this something that is possible to do?

Functions PHP code which toggles the light and dark mode

$zox_dark_mode = get_option('zox_dark_mode');
    if ($zox_dark_mode !== "2" && $zox_dark_mode !== "3") {
    wp_add_inline_script( 'zox-custom', '
    jQuery(document).ready(function($) {
        $(".zox-night-mode").on("click", function(){
            if (localStorage.toggled != "zox-dark") {
                $("#zox-site").toggleClass("zox-dark", true);
                localStorage.toggled = "zox-dark";
            } else {
                $("#zox-site").toggleClass("zox-dark", false);
                localStorage.toggled = "";
    ' );

My HTML CSS class is .slider-container and the class I want to toggle to is slider-dark. I tried adding it in the code but it doesn’t work and even breaks down the toggler.

newbiefatcoder 4 months 0 Answers 13 views 0

Leave an answer