You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+28-2Lines changed: 28 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,11 +2,17 @@
2
2
3
3
WordPress Plugin providing a "accept" banner before embedding Google Analytics (and other scripts that can be registered)
4
4
5
+
## Settings
6
+
7
+
This plugin has a setting page under "Tools".
8
+
There, you can set some common Analytics codes, and disable the banner altogether if you only use
9
+
the Gutenberg part of it.
10
+
5
11
## API
6
12
7
13
### PHP
8
14
9
-
You can use, for example,
15
+
You can use, for example,
10
16
11
17
```php
12
18
if (function_exists('wpca_enqueue_script')){
@@ -24,5 +30,25 @@ Do this wherever (i.e., in a init hook) you would do the `wp_enqueue_script`.
24
30
This plugin exposes the following global functions:
25
31
26
32
```javascript
27
-
33
+
wpcaCookiesAreAllowed(); // returns whether all cookies are allowed
34
+
wpcaAcceptCookies(); // trigger "accept all cookies"
35
+
wpcaContentTypeIsAllowed(contentType); // returns whether the given content type is allowed
36
+
wpcaAcceptContentType(contentType); // trigger "accept the given content type"
28
37
```
38
+
39
+
Additionally, the event `wpcaCookiesAccepted` is triggered when all cookies are accepted,
40
+
and `wpcaContentTypeAccepted` is triggered if a certain subset of cookies for one content type is accepted.
41
+
42
+
### Gutenberg
43
+
44
+
This plugin provides a Gutenberg block, called "External Content Wrapper",
45
+
which blocks the child blocks from being rendered until sufficient cookie permissions are given.
46
+
47
+
#### Usage Example
48
+
49
+
1. Add the "External Content Wrapper" block to your post/page
50
+
2. Select the content type (Analytics, Marketing, Social Media, etc.)
51
+
3. Add your content blocks inside the wrapper
52
+
4. The content will only be displayed after the user accepts the corresponding cookie type
53
+
54
+
This is particularly useful for embedding content from external sources like YouTube videos, Google Maps, or social media feeds that may track user data.
0 commit comments