Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setting european CDN to use https://consent.cookiebot.eu instead … #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .craftplugin
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"pluginName":"Cookiebot","pluginDescription":"CookieBot integration into Craft CMS.","pluginVersion":"2.1.2","pluginAuthorName":"Human Direct","pluginVendorName":"humandirect","pluginAuthorUrl":"https://humandirect.eu","pluginAuthorGithub":"","codeComments":"yes","pluginComponents":["services","utilities","variables"],"consolecommandName":"","controllerName":"","cpsectionName":"","elementName":"","fieldName":"","modelName":"","purchasableName":"","recordName":"","serviceName":"","taskName":"","utilityName":"","widgetName":"","apiVersion":"api_version_3_0"}
{"pluginName":"Cookiebot","pluginDescription":"CookieBot integration into Craft CMS.","pluginVersion":"2.1.3","pluginAuthorName":"Human Direct","pluginVendorName":"humandirect","pluginAuthorUrl":"https://humandirect.eu","pluginAuthorGithub":"","codeComments":"yes","pluginComponents":["services","utilities","variables"],"consolecommandName":"","controllerName":"","cpsectionName":"","elementName":"","fieldName":"","modelName":"","purchasableName":"","recordName":"","serviceName":"","taskName":"","utilityName":"","widgetName":"","apiVersion":"api_version_3_0"}
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@
## 1.0.7 - 2019-04-20
### Fixed
- Upgraded cookiebot support for version 2 of the cookie, that handles cookies that don't require consent
## 2.1.3 - 2023-09-27
### Added
- Option to change TLD
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ Here’s what that config file might look like along with a list of all of the p
'domainGroupID' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
'defaultPreferences' => true,
'defaultStatistics' => true,
'defaultMarketing' => false
'defaultMarketing' => false,
'europeanCDN' => false
];
```

Expand Down
3 changes: 3 additions & 0 deletions src/models/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Settings extends Model
public bool $defaultStatistics = false;
public bool $defaultMarketing = false;
public bool $autoBlockingMode = false;
public bool $europeanCDN = false;

/**
* @inheritdoc
Expand All @@ -34,6 +35,8 @@ public function rules(): array
['defaultMarketing', 'default', 'value' => false],
['autoBlockingMode', 'boolean'],
['autoBlockingMode', 'default', 'value' => false],
['europeanCDN', 'boolean'],
['europeanCDN', 'default', 'value' => false],
];
}
}
1 change: 1 addition & 0 deletions src/services/CookiebotService.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ private function renderScript(string $type, string $culture = null): string
$vars['domainGroupID'] = $settings->domainGroupID;
$vars['culture'] = $culture;
$vars['autoBlockingMode'] = $settings->autoBlockingMode;
$vars['CDNdomain'] = $settings->europeanCDN ? 'eu' : 'com';

$oldMode = \Craft::$app->view->getTemplateMode();
\Craft::$app->view->setTemplateMode(View::TEMPLATE_MODE_CP);
Expand Down
2 changes: 1 addition & 1 deletion src/templates/scripts/declaration.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script type="text/javascript"
id="CookieDeclaration"
src="https://consent.cookiebot.com/{{ domainGroupID }}/cd.js"
src="https://consent.cookiebot.{{ CDNdomain }}/{{ domainGroupID }}/cd.js"
{% if culture %}data-culture="{{ culture|upper }}"{% endif %}
{% if autoBlockingMode == true %}data-blockingmode="auto"{% else %}async{% endif %}></script>
2 changes: 1 addition & 1 deletion src/templates/scripts/dialog.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script type="text/javascript"
id="Cookiebot"
src="https://consent.cookiebot.com/uc.js"
src="https://consent.cookiebot.{{ CDNdomain }}/uc.js"
data-cbid="{{ domainGroupID }}"
{% if culture %}data-culture="{{ culture|upper }}"{% endif %}
{% if autoBlockingMode == true %}data-blockingmode="auto"{% else %}async{% endif %}></script>
11 changes: 11 additions & 0 deletions src/templates/settings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@
errors: settings.getErrors('autoBlockingMode')
}) }}

{{ forms.lightswitchField({
label: "Use .eu TLD instead of .com for loading cookiebot"|t,
on: settings.europeanCDN,
toggle: true,
id: 'europeanCDN',
name: 'europeanCDN',
disabled: 'europeanCDN' in overrides,
warning: 'europeanCDN' in overrides ? configWarning('europeanCDN'),
errors: settings.getErrors('europeanCDN')
}) }}

<hr>
<div class="field" id="settings-prependSender-field">
<div class="heading">
Expand Down