Skip to content

Commit e1ea108

Browse files
committed
Fix merge conflict
2 parents 3bcd8a1 + 81a23a2 commit e1ea108

15 files changed

+336
-118
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<<<<<<< HEAD
12
### 1.3.0: 2024-12-12
23

34
* Update PUC to v5 (T-23373)
@@ -10,6 +11,8 @@
1011

1112
* Run all cookie JS scripts on page load
1213

14+
=======
15+
>>>>>>> 81a23a22
1316
### 1.2.8: 2024-05-10
1417

1518
* Don't send consent POST request with every request (issue #2)

README.md

Lines changed: 75 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88

99
Air cookie provides simple cookie banner and management.
1010

11-
Uses the [CookieConsent](https://orestbida.com/demo-projects/cookieconsent/) javascript plugin as a base, making its usage with WordPress easier.
11+
Uses the [CookieConsent V3.0.0](https://playground.cookieconsent.orestbida.com/) javascript plugin as a base, making its usage with WordPress easier.
1212

1313
# Features
1414

1515
- Simple and lightweight cookie banner
1616
- Third party embeds blocking until cookies accepted
17+
- Allows to remove cookies after changing consent
1718
- Easy to load scripts and execute custom javascript when cookies are accepted
1819
- Support for multiple different cookie categories
1920
- Polylang support for multilingual websites
@@ -27,15 +28,15 @@ Uses the [CookieConsent](https://orestbida.com/demo-projects/cookieconsent/) jav
2728
Remember to add a link into the footer, which allows opening the cookie settings anytime!
2829

2930
```html
30-
<a href="#" data-cc="c-settings" class="cc-link">Cookie settings</a>
31+
<button type="button" data-cc="show-preferencesModal">View cookie settings</button>
3132
```
3233

3334
If you have Polylang installed and active, use
3435

3536
```html
36-
<a href="#" data-cc="c-settings" class="cc-link">
37+
<button type="button" data-cc="show-preferencesModal">
3738
<?php echo pll_translate_string( 'Evästeasetukset', pll_current_language() ); ?>
38-
</a>
39+
</button>
3940
```
4041

4142
## Cookie categories
@@ -50,7 +51,7 @@ function my_add_cookie_category( $categories ) {
5051
'enabled' => false, // it is advised to have categories disabled by default
5152
'readonly' => false, // user should have always control over categories
5253
'title' => 'Ads',
53-
'description' => 'This site uses external services to display ads, and they might set some cookies.',
54+
'description' => 'This site uses external services to display ads, and they might set some cookies.', // Check how to remove cookies from example below.
5455
];
5556

5657
return $categories;
@@ -60,13 +61,68 @@ function my_add_cookie_category( $categories ) {
6061
When adding new categories, the function itself is responsile for handling the translations for title and description.
6162

6263
There is also `air_cookie\categories\{category-key}` filter available to change the settings of indivual category.
64+
```php
65+
add_filter( 'air_cookie\categories\{analytics}', 'my_change_category_analytics' );
66+
function my_change_category_analytics( $edited_categoy ) {
67+
$edited_category = [
68+
'key' => 'analytics',
69+
'enabled' => false,
70+
'readonly' => false,
71+
'title' => 'Analytics',
72+
'description' => 'This site uses Google Analytics and it set some cookies. Read more about those from privacy policy.',
73+
'auto_clear' => [ // Optional: auto_clear allows you to define cookies, which will be removed after changing consent. List all cookies to correct categories. Possible to use string or regex format (format is a bit different than official docs points out! https://cookieconsent.orestbida.com/reference/configuration-reference.html#category-autoclear).
74+
'cookies' => [
75+
[
76+
'name' => '^(_ga)', // Match all cookies starting with '_ga',
77+
],
78+
[
79+
'name' => '_gid',
80+
],
81+
],
82+
],
83+
];
84+
85+
return $edited_category;
86+
}
87+
```
88+
89+
ℹ If you add Google Analytics, remember [Google consent mode](https://developers.google.com/tag-platform/security/guides/consent?consentmode=advanced#upgrade-consent-v2) scripts.
6390

91+
```javascript
92+
<script
93+
type="text/plain"
94+
data-category="analytics">
95+
// Executed when the "analytics" category is enabled. Use this snippet after defining GA.
96+
window.dataLayer = window.dataLayer || [];
97+
function gtag() { dataLayer.push(arguments); }
98+
gtag('consent', 'default', {
99+
'ad_storage': 'denied',
100+
'analytics_storage': 'granted',
101+
'ad_user_data': 'denied',
102+
'ad_personalization': 'denied'
103+
});
104+
</script>
105+
106+
<script
107+
type="text/plain"
108+
data-category="!analytics">
109+
// Executed when the "analytics" category is disabled. Use this snippet after defining GA.
110+
window.dataLayer = window.dataLayer || [];
111+
function gtag() { dataLayer.push(arguments); }
112+
gtag('consent', 'update', {
113+
'ad_storage': 'denied',
114+
'analytics_storage': 'denied',
115+
'ad_user_data': 'denied',
116+
'ad_personalization': 'denied'
117+
});
118+
</script>
119+
```
64120
## Loading scripts after cookies have been accepted
65121

66122
The easiest way to load external script is by altering the `script` tag to be:
67123

68124
```html
69-
<script type="text/plain" data-src="<uri-to-script>" data-cookiecategory="analytics" defer>
125+
<script type="text/plain" data-src="<uri-to-script>" data-category="analytics">
70126
```
71127
72128
The example above works only, if the script does not require any extra javascript to be executed after the script has been loaded. If you need to execute extra javascript, use the example below.
@@ -75,7 +131,7 @@ The example above works only, if the script does not require any extra javascrip
75131
add_action( 'air_cookie_js_analytics', 'my_add_js_for_analytics' );
76132
function my_add_js_for_analytics() {
77133
ob_start(); ?>
78-
cc.loadScript( 'https://www.google-analytics.com/analytics.js', function() {
134+
CookieConsent.loadScript( 'https://www.google-analytics.com/analytics.js', function() {
79135
ga('create', 'UA-XXXXXXXX-Y', 'auto'); //replace UA-XXXXXXXX-Y with your tracking code
80136
ga('send', 'pageview');
81137
} );
@@ -109,7 +165,7 @@ function my_add_js_for_analytics() {
109165
add_action( 'air_cookie_js_analytics', 'my_add_js_for_analytics' );
110166
function my_add_js_for_analytics() {
111167
ob_start(); ?>
112-
cc.loadScript( 'https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXXX-X', function() {
168+
CookieConsent.loadScript( 'https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXXX-X', function() {
113169
window.dataLayer = window.dataLayer || [];
114170
function gtag(){dataLayer.push(arguments);}
115171
gtag('js', new Date());
@@ -125,7 +181,7 @@ function my_add_js_for_analytics() {
125181
add_action( 'air_cookie_js_analytics', 'my_add_js_for_analytics' );
126182
function my_add_js_for_analytics() {
127183
ob_start(); ?>
128-
cc.loadScript( 'https://www.google-analytics.com/analytics.js', function() {
184+
CookieConsent.loadScript( 'https://www.google-analytics.com/analytics.js', function() {
129185
ga('create', 'UA-XXXXXXXX-Y', 'auto'); //replace UA-XXXXXXXX-Y with your tracking code
130186
ga('send', 'pageview');
131187
} );
@@ -153,7 +209,7 @@ add_action( 'air_cookie_js_functional', function() {
153209
}
154210
155211
ob_start(); ?>
156-
cc.loadScript( '<?php echo esc_url( $stampedio_url ) ?>' );
212+
CookieConsent.loadScript( '<?php echo esc_url( $stampedio_url ) ?>' );
157213
<?php echo ob_get_clean(); // phpcs:ignore
158214
} ); // end woocommerce_ga_integration_script_for_air_cookie
159215
@@ -182,7 +238,7 @@ function woocommerce_stampedio_script_for_air_cookie() {
182238
}
183239
184240
ob_start(); ?>
185-
cc.loadScript( '<?php echo esc_url( $stampedio_url ) ?>' );
241+
CookieConsent.loadScript( '<?php echo esc_url( $stampedio_url ) ?>' );
186242
<?php echo ob_get_clean(); // phpcs:ignore
187243
} // end woocommerce_ga_integration_script_for_air_cookie
188244
```
@@ -207,7 +263,7 @@ function my_add_js_for_<category-key>() {
207263
If you wish to use your own `script` tag, it is possible with example below
208264
209265
```javascript
210-
<script type="text/plain" data-cookiecategory="<category-key>">
266+
<script type="text/plain" data-category="<category-key>">
211267
console.log( 'Hello world!' );
212268
</script>
213269
```
@@ -234,28 +290,28 @@ document.addEventListener( 'air_cookie', (event) => {
234290
235291
## Changing settings
236292
237-
Setting names do follow the [CookieConsents option](https://github.com/orestbida/cookieconsent#apis--configuration-parameters) names. Some settings defaults are set to be different than the CookieConsent defaults:
293+
Setting names do follow the [CookieConsents option](https://cookieconsent.orestbida.com/reference/configuration-reference.html#configuration-reference) names. Some settings defaults are set to be different than the CookieConsent defaults:
238294
239295
Setting | Value
240296
--- | ---
241-
`cookie_name` | air_cookie
242-
`current_lang` | _value from polylang or locale option_
297+
cookie/name | air_cookie
243298
`revision` | _automatically calculated from cookie categories_
244-
`page_scripts` | true
245-
gui_options/consent_modal/layout | box
246-
gui_options/consent_modal/position | bottom left
299+
settings/language/default | _value from polylang or locale option_
300+
guiOptions/consentModal/layout | cloud inline
301+
guiOptions/consentModal/position | bottom center
247302
248303
You may change the settings with `air_cookie\settings` filter which contains all settings or `air_cookie\settings\{setting-name}` filter for indivual setting.
249304
250305
```php
251306
add_filter( 'air_cookie\settings', 'my_modify_cc_settings' );
252307
function my_modify_cc_settings( $settings ) {
253-
$settings['page_scripts'] = false;
308+
$settings['gui_options']['consent_modal']['position'] = "top right";
254309
return $settings;
255310
}
256311
```
257312
258313
```php
314+
// page_scripts not used in CC 3.0.0
259315
add_filter( 'air_cookie\settings\page_scripts', 'my_modify_cc_setting_page_scripts' );
260316
function my_modify_cc_setting_page_scripts( $setting ) {
261317
return false;

air-cookie.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@
33
* Plugin Name: Air cookie
44
* Plugin URI: https://github.com/digitoimistodude/air-cookie
55
* Description: Simple cookie banner and management.
6+
<<<<<<< HEAD
67
* Version: 1.3.0
8+
=======
9+
* Version: 1.2.8
10+
>>>>>>> 81a23a22
711
* Author: Digitoimisto Dude Oy
812
* Author URI: https://www.dude.fi
913
* Requires at least: 5.5
1014
* Tested up to: 6.4.3
1115
* License: GPL-3.0+
1216
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
17+
* @Modified by: Jesse Raitapuro (Digiaargh)
18+
* @Modified time: 2024-04-22 16:30:00
1319
*
1420
* @package air-cookie
1521
*/
@@ -27,8 +33,12 @@
2733
* @since 0.1.0
2834
*/
2935
function get_plugin_version() {
36+
<<<<<<< HEAD
3037
// 5 digits, 1.3.0 -> 10300
3138
return 13000;
39+
=======
40+
return 128;
41+
>>>>>>> 81a23a22
3242
} // end plugin_version
3343

3444
/**
@@ -47,7 +57,7 @@ function get_database_version() {
4757
* @since 0.1.0
4858
*/
4959
function get_script_version() {
50-
return '2.9.1';
60+
return '3.0.1';
5161
} // end get_script_version
5262

5363
/**
@@ -58,7 +68,6 @@ function get_script_version() {
5868
require 'plugin-helpers.php';
5969

6070
/**
61-
* Github updater.
6271
*
6372
* @since 0.1.0
6473
*/

assets/cookieconsent.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/cookieconsent.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)