Jump to content

Adding Cookie Control to Client Pages


wpmattuk

Recommended Posts

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 🙂

 

Link to comment
Share on other sites

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");

HcXyqiU.png

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 11 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated