Skip to content
This repository was archived by the owner on Jun 28, 2025. It is now read-only.

Commit d235d73

Browse files
author
michnhokn
committed
Merge branch 'release/1.0.9'
2 parents 1c04714 + 44e10e4 commit d235d73

File tree

4 files changed

+30
-17
lines changed

4 files changed

+30
-17
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "michnhokn/kirby3-cookie-banner",
33
"description": "Add a cookie modal to your Kirby3 website",
44
"type": "kirby-plugin",
5-
"version": "1.0.8",
5+
"version": "1.0.9",
66
"license": "MIT",
77
"authors": [
88
{

index.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,23 @@
33
@include_once __DIR__ . '/vendor/autoload.php';
44
require_once __DIR__ . '/lib/CookieMethods.php';
55

6+
const DEFAULT_CONTENT = [
7+
'title' => 'Cookie Einstellungen',
8+
'text' => 'Wir nutzen Cookies um Dir die bestmögliche Erfahrung zu bieten. Außerdem können wir damit das Verhalten der Benutzer analysieren um die Webseite stetig für Dich zu verbessern. (link: datenschutz text: Datenschutz)',
9+
'essentialText' => 'Essentiell',
10+
'denyAll' => 'Alle ablehnen',
11+
'acceptAll' => 'Alle annehmen',
12+
'save' => 'Einstellung speichern',
13+
];
14+
615
Kirby::plugin('michnhokn/cookie-banner', [
716
'snippets' => [
817
'cookie-modal' => __DIR__ . '/snippets/cookie-modal.php',
918
'cookie-modal-option' => __DIR__ . '/snippets/cookie-modal-option.php',
1019
],
1120
'translations' => [
1221
'de' => [
13-
'michnhokn.cookie-banner.title' => 'Cookie Einstellungen',
14-
'michnhokn.cookie-banner.text' => 'Wir nutzen Cookies um Dir die bestmögliche Erfahrung zu bieten. Außerdem können wir damit das Verhalten der Benutzer analysieren um die Webseite stetig für Dich zu verbessern. (link: datenschutz text: Datenschutz)',
15-
'michnhokn.cookie-banner.essentialText' => 'Essentiell',
16-
'michnhokn.cookie-banner.denyAll' => 'Alle ablehnen',
17-
'michnhokn.cookie-banner.acceptAll' => 'Alle annehmen',
18-
'michnhokn.cookie-banner.save' => 'Einstellung speichern',
22+
'michnhokn.cookie-banner' => DEFAULT_CONTENT
1923
],
2024
'en' => [
2125
'michnhokn.cookie-banner.title' => 'Cookie settings',
@@ -27,6 +31,7 @@
2731
]
2832
],
2933
'options' => [
30-
'features' => []
34+
'features' => [],
35+
'content' => DEFAULT_CONTENT
3136
]
3237
]);

lib/CookieMethods.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,11 @@ function clearAllowedFeatures()
3232
{
3333
return \Kirby\Http\Cookie::remove('cookie_status');
3434
}
35+
36+
function getCookieModalTranslation($key)
37+
{
38+
if (option('languages')) {
39+
return t("michnhokn.cookie-banner.$key");
40+
}
41+
return option("michnhokn.cookie-banner.content.$key");
42+
}

snippets/cookie-modal.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
<div class="cookie-modal cookie-modal--hidden" id="cookie-modal"
1111
data-show-on-first="<?= $showOnFirst ? 'true' : 'false' ?>">
1212
<div class="cookie-modal__content">
13-
<p class="cookie-modal__title"><?= t('michnhokn.cookie-banner.title') ?></p>
14-
<p class="cookie-modal__text"><?= kti(t('michnhokn.cookie-banner.text')) ?></p>
13+
<p class="cookie-modal__title"><?= getCookieModalTranslation('title') ?></p>
14+
<p class="cookie-modal__text"><?= kti(getCookieModalTranslation('text')) ?></p>
1515
<div class="cookie-modal__options">
1616
<?php snippet('cookie-modal-option', [
1717
'disabled' => true,
1818
'checked' => true,
1919
'key' => 'essential',
20-
'title' => t('michnhokn.cookie-banner.essentialText')
20+
'title' => getCookieModalTranslation('essentialText')
2121
]) ?>
2222
<?php foreach ($features as $key => $title): ?>
2323
<?php snippet('cookie-modal-option', [
@@ -29,16 +29,16 @@
2929
</div>
3030
<div class="cookie-modal__buttons">
3131
<a href="#" class="cookie-modal__button primary" id="cookie-accept"
32-
title="<?= t('michnhokn.cookie-banner.acceptAll') ?>">
33-
<span><?= t('michnhokn.cookie-banner.acceptAll') ?></span>
32+
title="<?= getCookieModalTranslation('acceptAll') ?>">
33+
<span><?= getCookieModalTranslation('acceptAll') ?></span>
3434
</a>
3535
<a href="#" class="cookie-modal__button" id="cookie-deny"
36-
title="<?= t('michnhokn.cookie-banner.denyAll') ?>">
37-
<span><?= t('michnhokn.cookie-banner.denyAll') ?></span>
36+
title="<?= getCookieModalTranslation('denyAll') ?>">
37+
<span><?= getCookieModalTranslation('denyAll') ?></span>
3838
</a>
3939
<a href="#" class="cookie-modal__button hide" id="cookie-save"
40-
title="<?= t('michnhokn.cookie-banner.save') ?>">
41-
<span><?= t('michnhokn.cookie-banner.save') ?></span>
40+
title="<?= getCookieModalTranslation('save') ?>">
41+
<span><?= getCookieModalTranslation('save') ?></span>
4242
</a>
4343
</div>
4444
</div>

0 commit comments

Comments
 (0)