• Resolved oliverjuwig

    (@oliverjuwig)


    Hello,

    I have a somewhat tricky question. WP allows for Youtube header videos and my site uses this feature within a highly customized Twenty Seventeen theme. With respect to the GDPR, I want to enable the header video only, if the user accepted the cookie notice. If not – and also, before the consent is given – I want to show the still image for the header.

    I looked into the documentation, but I found no filter or something else to disable/enable the header video programmatically. In the end, a filter solution will not work anyway, since my site relies on static page caching. The solution must therefore use CSS/JS, not PHP.

    Anyone here with some voodo skills around header videos?

    Best regards

    Oliver

    • This topic was modified 6 years, 7 months ago by oliverjuwig.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Moved to Fixing WordPress, this is not a Developing with WordPress topic.

    Thread Starter oliverjuwig

    (@oliverjuwig)

    I found a solution on my own:

    
    function getCookie(cname) {
        var name = cname + "=";
        var decodedCookie = decodeURIComponent(document.cookie);
        var ca = decodedCookie.split(';');
        for(var i = 0; i <ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0) == ' ') {
                c = c.substring(1);
            }
            if (c.indexOf(name) == 0) {
                return c.substring(name.length, c.length);
            }
        }
        return "";
    }
    
    jQuery(document).ready(function( $ ){
        var supportsVideo = wp.customHeader.supportsVideo;
      
        wp.customHeader.supportsVideo = function() {
            return supportsVideo() && (getCookie('cookie_notice_accepted') == 'false'); }
    });
    

    Note: The cookie ‘cookie_notice_accepted’ will be set to ‘false’, if the user accepts…

    • This reply was modified 6 years, 7 months ago by oliverjuwig.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Disable Header video until user consent is given’ is closed to new replies.