-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGet_Head_CookieCompliance.php
68 lines (63 loc) · 3.5 KB
/
Get_Head_CookieCompliance.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
function Get_Cookie_Compliance_Head()
{
global $page;
global $addonPathData;
$configFile = $addonPathData.'/config.php';
if( ! file_exists( $configFile ) )
{
return;
}
include_once $configFile;
if( ! isset( $config ) )
{
return;
}
$button_color = $config['button_color'];
$button_text_color = $config['button_text_color'];
$background_color = $config['background_color'];
$text_color = $config['text_color'];
$header_text = $config['header_text'];
$text = $config['text'];
$agree_button_text = $config['agree_button_text'];
$policy_button_text = $config['policy_button_text'];
$policy_url = $config['policy_url'];
$page->head .= "\n";
$page->head .= "\n<link rel='stylesheet' type='text/css' href='//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.3/cookieconsent.min.css' />";
$page->head .= "\n<script src='//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.3/cookieconsent.min.js'></script>";
$page->head .= "\n<script>";
$page->head .= "\nwindow.addEventListener('load', function(){";
$page->head .= "\nwindow.cookieconsent.initialise({";
$page->head .= "\n 'layout': 'custom-layout',";
$page->head .= "\n 'layouts': {";
$page->head .= "\n 'custom-layout': '<div class=\"cc-custom-layout\">\\";
$page->head .= "\n {{header}}{{messagelink}}</div>{{compliance}}',";
$page->head .= "\n },";
$page->head .= "\n 'palette': {";
$page->head .= "\n 'popup': {";
$page->head .= "\n 'background': '#".$background_color."',";
$page->head .= "\n 'text': '#".$text_color."'";
$page->head .= "\n },";
$page->head .= "\n 'button': {";
$page->head .= "\n 'background': '#".$button_color."',";
$page->head .= "\n 'text': '#".$button_text_color."'";
$page->head .= "\n }";
$page->head .= "\n },";
$page->head .= "\n 'content': {";
$page->head .= "\n 'header': '".$header_text."',";
$page->head .= "\n 'message': '".$text."',";
$page->head .= "\n 'dismiss': '".$agree_button_text."',";
$page->head .= "\n 'link': '".$policy_button_text."',";
$page->head .= "\n 'href': '".$policy_url."'";
$page->head .= "\n },";
$page->head .= "\n 'elements': {";
$page->head .= "\n 'header': '<small class=\"cc-custom-header\"><strong>{{header}} -</strong></small> ',";
$page->head .= "\n 'message': '<small id=\"cookieconsent:desc\" class=\"cc-message\">{{message}}</small>',";
$page->head .= "\n 'messagelink': '<small id=\"cookieconsent:desc\" class=\"cc-message\">{{message}} <a aria-label=\"learn more about cookies\" tabindex=\"0\" class=\"cc-link\" href=\"{{href}}\" target=\"_blank\">{{link}}</a></small>',";
$page->head .= "\n 'link': '<a aria-label=\"learn more about cookies\" tabindex=\"0\" class=\"cc-link\" href=\"{{href}}\" target=\"_blank\"><small>{{link}}</small></a>',";
$page->head .= "\n }";
$page->head .= "\n})});";
$page->head .= "\n</script>";
$page->head .= "\n";
}
?>