wpmattuk Posted February 15, 2019 Share Posted February 15, 2019 Hi all I use Cookie Control from Termsfeed for GDPR-compliance purposes. I have incorporated their code into my existing site pages, but also need to do this into WHMCS; this will be my first customisation of it. I've been trying to find advice/guidance on how to achieve this, but in doing so I think I've confused myself rather than actually helping! From what I can make out (having seen various replies by @brian!) I should use ClientAreaOutput hooks, but I've no idea how to do so. The code that I need to add is - <!-- Cookie Consent by https://TermsFeed.com --> <script type="text/javascript" src="//termsfeed.com/cookie-consent/releases/3.0.0/cookie-consent.js"></script> <script type="text/javascript"> document.addEventListener('DOMContentLoaded', function () { cookieconsent.run({"notice_banner_type":"headline","consent_type":"express","palette":"dark","change_preferences_selector":"#changePreferences","language":"en"}); }); </script> <noscript><a href="https://termsfeed.com/cookie-consent/">Cookie Consent by TermsFeed</a></noscript> <!-- End Cookie Consent --> Can someone please point me in the right direction so that I can get this code added correctly? Thanks in advance 🙂 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 15, 2019 Share Posted February 15, 2019 25 minutes ago, thisismatt said: Can someone please point me in the right direction so that I can get this code added correctly? the following hook should work for you @thisismatt... <?php # Matt's Cookie Hook # Written by brian! function thisismatt_cookie_hook($vars) { return <<<HTML <!-- Cookie Consent by https://TermsFeed.com --> <script type="text/javascript" src="//termsfeed.com/cookie-consent/releases/3.0.0/cookie-consent.js"></script> <script type="text/javascript"> document.addEventListener('DOMContentLoaded', function () { cookieconsent.run({"notice_banner_type":"headline","consent_type":"express","palette":"dark","change_preferences_selector":"#changePreferences","language":"en"}); }); </script> <noscript><a href="https://termsfeed.com/cookie-consent/">Cookie Consent by TermsFeed</a></noscript> <!-- End Cookie Consent --> HTML; } add_hook("ClientAreaFooterOutput", 1, "thisismatt_cookie_hook"); 2 Quote Link to comment Share on other sites More sharing options...
wpmattuk Posted February 15, 2019 Author Share Posted February 15, 2019 Brian, thank you; you are utterly helpful and selfless. BUT....where do I put this? That's probably the biggest lack of understanding I have I'm afraid, what exactly do I do with this code now? Thanks again! 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 15, 2019 Share Posted February 15, 2019 Just now, thisismatt said: BUT....where do I put this? answers on a postcard, please! 😛 upload the attached file to /includes/hooks (or create a new .php file in there and copy&paste the above code) and the next time you refresh your site in the browser, you should see the cookie bar... 🙂 thisimattcookie.php 0 Quote Link to comment Share on other sites More sharing options...
wpmattuk Posted February 15, 2019 Author Share Posted February 15, 2019 If I could I'd kiss you @brian!; thank you so much. It's worked a dream. So this is the correct way to add code to templates without risk of them being overwritten during updates? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 15, 2019 Share Posted February 15, 2019 8 minutes ago, thisismatt said: So this is the correct way to add code to templates without risk of them being overwritten during updates? yes... occasionally, I think you might need to output in the header instead of the footer (depending on what you're trying to do), but the Google Analytics addon uses a ClientAreaFooterOutput in the same way as your hook. 0 Quote Link to comment Share on other sites More sharing options...
artaweb Posted February 11, 2020 Share Posted February 11, 2020 (edited) Hi Brian How can I add a code right before </head> tag closing? I change the FooterOutput to HeaderOutput, it worked but the code is right after </head> closing (inside opening of body, first line). Edited February 11, 2020 by artaweb 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 11, 2020 Share Posted February 11, 2020 7 minutes ago, artaweb said: How can I add a code right before </head> tag closing? I change the FooterOutput to HeaderOutput, it worked but the code is right after </head> closing (inside opening of body, first line). change it to ClientAreaHeadOutput 🙂 1 Quote Link to comment Share on other sites More sharing options...
artaweb Posted February 11, 2020 Share Posted February 11, 2020 Thank you Brian. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.