php helper function not working?
-
Hi,
I have tried using the ‘ is_allowed_cookie( $cookie ) ‘ helper function to wrap code to block a cookie, I have experimented with a google gpt publisher tag snippet to see if I can get the helper function to work. The cookie is registered as an optional cookie under Advertising. What am I missing here?
Should the function not somehow be added to the functions.php file first and/or in a child theme?
What I have done looks like this:
if ( is_allowed_cookie( ‘CONSENT’ ) {
// Run my code and set the cookie.
<script async src=”https://securepubads.g.doubleclick.net/tag/js/gpt.js”></script>
}
<script>
window.googletag = window.googletag || {cmd: []};
googletag.cmd.push(function() {
googletag.defineSlot(‘/21714798789/GE-Native-Bloc1’, [[250, 360], [300, 600], ‘fluid’], ‘div-gpt-ad-**********-0’).addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.pubads().collapseEmptyDivs();
googletag.enableServices();
});
</script> (I blanked out the Ad number)But i have tried it several different ways, with several different cookies that are set by that same script.
The Ad code with the wrap function is injected into the header of each chosen post/page via Ad-Inserter, a plugin for injecting ad code, or any code, into chosen posts/pages on a site. But that shouldn’t make any difference surely?
Clearly i am missing something, no?
- The topic ‘php helper function not working?’ is closed to new replies.