Skip to content

Commit

Permalink
Merge branch 'release/1.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
michnhokn committed Sep 15, 2020
2 parents 46bc8de + 417c962 commit 7b7b192
Show file tree
Hide file tree
Showing 16 changed files with 215 additions and 220 deletions.
28 changes: 11 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,18 @@ This plugin is free but if you use it in a commercial project please consider to
- `composer require michnhokn/kirby3-cookie-banner`

## Features
- Add custom options to cookie banner
- Add custom features to cookie modal
- You can fully translate the cookie banner ([Custom language variables](https://getkirby.com/docs/guide/languages/custom-language-variables))
- Check the state of the cookie banner via JavaScript events
- Check in code for allowed features
- Intercept cookie status via JavaScript event
- PHP functions to check for allowed features
- Trigger JavaScript event to update Cookie Modal

## Setup
To setup the cookie banner just put the `cookie-banner` snippet right befor your closing body tag. Thats it. 🎉
To setup the cookie banner just put the `cookie-modal` snippet right befor your closing body tag. Thats it. 🎉
``` php
<?php snippet('cookie-banner') ?>
<?php snippet('cookie-modal') ?>
```
If a selection is made in the cookie modal, a corresponding event is fired on `<body>`.

| Event | Reason |
|---|---|
| `cookies:all` | all cookies are accepted |
| `cookies:deny` | only essential cookies are accepted |
| `cookies:custom` | some cookies are accepted |

Every event contains a comma separated string of selected options.
If a selection is made an event called `cookies:saved` is triggerd on `<body>`. The included data contains an array of allowed features.
You can set these up in your `config.php` file under `site/config/`.
````php
return [
Expand All @@ -46,6 +39,8 @@ return [
];
````

The modal can be recalled and edited by triggering the event `cookies:update` on the `<bod>` tag.

## Methods
- `isFeatureAllowed(string $featureName)` Checks if a user allowed given feature
```php
Expand All @@ -57,9 +52,8 @@ return [
- `clearAllowedFeatures()` Clear all allowed features

## Roadmap

- Better custom theme
- Set up Wiki
- Add wiki
- Refactor code + add comments

---

Expand Down
1 change: 0 additions & 1 deletion assets/cookie-banner.css

This file was deleted.

8 changes: 0 additions & 8 deletions assets/cookie-banner.js

This file was deleted.

1 change: 1 addition & 0 deletions assets/cookie-modal.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7b7b192

Please sign in to comment.