Skip to content

Commit

Permalink
Merge branch 'release/1.0.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
michnhokn committed Feb 15, 2021
2 parents 1c04714 + 44e10e4 commit d235d73
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 17 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "michnhokn/kirby3-cookie-banner",
"description": "Add a cookie modal to your Kirby3 website",
"type": "kirby-plugin",
"version": "1.0.8",
"version": "1.0.9",
"license": "MIT",
"authors": [
{
Expand Down
19 changes: 12 additions & 7 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,23 @@
@include_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/lib/CookieMethods.php';

const DEFAULT_CONTENT = [
'title' => 'Cookie Einstellungen',
'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)',
'essentialText' => 'Essentiell',
'denyAll' => 'Alle ablehnen',
'acceptAll' => 'Alle annehmen',
'save' => 'Einstellung speichern',
];

Kirby::plugin('michnhokn/cookie-banner', [
'snippets' => [
'cookie-modal' => __DIR__ . '/snippets/cookie-modal.php',
'cookie-modal-option' => __DIR__ . '/snippets/cookie-modal-option.php',
],
'translations' => [
'de' => [
'michnhokn.cookie-banner.title' => 'Cookie Einstellungen',
'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)',
'michnhokn.cookie-banner.essentialText' => 'Essentiell',
'michnhokn.cookie-banner.denyAll' => 'Alle ablehnen',
'michnhokn.cookie-banner.acceptAll' => 'Alle annehmen',
'michnhokn.cookie-banner.save' => 'Einstellung speichern',
'michnhokn.cookie-banner' => DEFAULT_CONTENT
],
'en' => [
'michnhokn.cookie-banner.title' => 'Cookie settings',
Expand All @@ -27,6 +31,7 @@
]
],
'options' => [
'features' => []
'features' => [],
'content' => DEFAULT_CONTENT
]
]);
8 changes: 8 additions & 0 deletions lib/CookieMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,11 @@ function clearAllowedFeatures()
{
return \Kirby\Http\Cookie::remove('cookie_status');
}

function getCookieModalTranslation($key)
{
if (option('languages')) {
return t("michnhokn.cookie-banner.$key");
}
return option("michnhokn.cookie-banner.content.$key");
}
18 changes: 9 additions & 9 deletions snippets/cookie-modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
<div class="cookie-modal cookie-modal--hidden" id="cookie-modal"
data-show-on-first="<?= $showOnFirst ? 'true' : 'false' ?>">
<div class="cookie-modal__content">
<p class="cookie-modal__title"><?= t('michnhokn.cookie-banner.title') ?></p>
<p class="cookie-modal__text"><?= kti(t('michnhokn.cookie-banner.text')) ?></p>
<p class="cookie-modal__title"><?= getCookieModalTranslation('title') ?></p>
<p class="cookie-modal__text"><?= kti(getCookieModalTranslation('text')) ?></p>
<div class="cookie-modal__options">
<?php snippet('cookie-modal-option', [
'disabled' => true,
'checked' => true,
'key' => 'essential',
'title' => t('michnhokn.cookie-banner.essentialText')
'title' => getCookieModalTranslation('essentialText')
]) ?>
<?php foreach ($features as $key => $title): ?>
<?php snippet('cookie-modal-option', [
Expand All @@ -29,16 +29,16 @@
</div>
<div class="cookie-modal__buttons">
<a href="#" class="cookie-modal__button primary" id="cookie-accept"
title="<?= t('michnhokn.cookie-banner.acceptAll') ?>">
<span><?= t('michnhokn.cookie-banner.acceptAll') ?></span>
title="<?= getCookieModalTranslation('acceptAll') ?>">
<span><?= getCookieModalTranslation('acceptAll') ?></span>
</a>
<a href="#" class="cookie-modal__button" id="cookie-deny"
title="<?= t('michnhokn.cookie-banner.denyAll') ?>">
<span><?= t('michnhokn.cookie-banner.denyAll') ?></span>
title="<?= getCookieModalTranslation('denyAll') ?>">
<span><?= getCookieModalTranslation('denyAll') ?></span>
</a>
<a href="#" class="cookie-modal__button hide" id="cookie-save"
title="<?= t('michnhokn.cookie-banner.save') ?>">
<span><?= t('michnhokn.cookie-banner.save') ?></span>
title="<?= getCookieModalTranslation('save') ?>">
<span><?= getCookieModalTranslation('save') ?></span>
</a>
</div>
</div>
Expand Down

0 comments on commit d235d73

Please sign in to comment.