Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1033310

    Hi,

    Currently, I have the GDPR bar just above the footer, where I have buttons.

    I want to move the GDPR bar below the buttons in the footer and have the GDPR bar collapse (disappear) when the user accepts.

    #1033384

    Hey corefocusgroup,
    You can move the GDPR bar below the socket, and it does disappear when clicked, but the socket doesn’t go back down.
    Please try this code in the General Styling > Quick CSS field:

    .avia-cookie-consent {
        bottom: 0px !important; 
    }
    #socket {
        bottom: 71px !important; 
    }
    

    You may be able to fix this with some javascript by applying the socket 71px only if there is no “.cookiebar-hidden” class, but I didn’t find some javascript that would do this.

    Best regards,
    Mike

    #1033386

    I managed to make a custom bar below the footer that will collapse. The problem is that I have to manually detect the “aviaCookieConsent” cookie and I haven’t been able to get that to work.

    I have two functions in functions.php: myFunction() and myFunction2(). myFunction() works and hides the DIV, but I can’t get myFunction2() to run on page load to evaluate if the cookie is present on page load.

    CODE BLOCK ON PAGE:

    
    <head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
    #myDIV {
        width: 100%;
        padding: 3px 0;
        text-align: center;
        background-color: #162946;
        margin-top: 10px;
    }
    </style>
    </head>
    <body onload="myFunction2()">
    
    <p>Click the "Try it" button to toggle between hiding and showing the DIV element:</p>
    
    <button onclick="myFunction()">Try it</button>
    
    <div id="myDIV">
    <a class="avia-button avia-cookie-consent-button avia-cookie-consent-button-1 avia-cookie-close-bar" data-contents="b35d8be8d2946ee5599f0c85b5cfb027" href="#" onclick="myFunction()">OK</a>
    </div>
    
    </body>
    

    CODE IN FUNCTIONS.PHP

    
    function custom_script_name(){
    ?>
    <script>
    function myFunction() {
        var x = document.getElementById("myDIV");
        if (x.style.display === "none") {
            x.style.display = "block";
        } else {
            x.style.display = "none";
        }
    }
    </script>
    <?php
    }
    add_action('wp_footer', 'custom_script_name');
    
    // End custom script in footer
    
    // I added this!
    //-------------------------------
    // Custom script in footer 
    // Detect cookie to toggle GDPR bar
    //-------------------------------
    
    function custom_script_name_2(){
    ?>
    <script>
    function myFunction2() {
        var x = document.getElementById("myDIV");
        if (!isset($_COOKIE['aviaCookieConsent'])) {
            x.style.display = "block";
        } else {
            x.style.display = "none";
        }
    }
    </script>
    <?php
    }
    add_action('wp_footer', 'custom_script_name_2');
    
    #1034452

    Hi,
    Sorry for the late reply and I don’t have a solution for this, but I also don’t understand the advantage of this over the built-in function that does disappear when the user clicks?
    If I understand correctly, the only thing you don’t like about the built-in function is that the bar shows above the socket & procharter-navbar, vs under it?
    Is this correct?

    Best regards,
    Mike

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.