Skip to content

Commit

Permalink
Update how-to-block-cookies.md
Browse files Browse the repository at this point in the history
  • Loading branch information
xzuttz authored Jun 22, 2018
1 parent bd928d1 commit 3d1484d
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions documentation/how-to-block-cookies.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ The Settings Service is used to store and retrieve settings.

Example settings:

- Check if the addon is installed or not.
- Get the placeholder text that should be displayed to renew ones consent.
- Get the tracking types that the addon needs consent for, if it should be executed
- Check if the addon is active or not.
- Get the placeholder text that should be displayed to renew a end-users consent
- Get the tracking types that the addon needs consent for

This will return the configured cookie types for an addon:
```
Expand All @@ -37,7 +37,7 @@ Script Loader Tag is used to manipulate the enqeueud scripts. It will add cookie

Example:

Below function will manipulate scripts added with the handle 'addtoany'. The second parameter will send the cookie types that were selected in the backend. Those types will be implemented into the data-cookieconsent attribute.
Below function will manipulate scripts added with the handle 'addtoany'. The second parameter will send the cookie types that were selected in the administration UI for the addon at hand. Those types will be implemented into the data-cookieconsent attribute.
```
$this->script_loader_tag->add_tag( 'addtoany', $this->get_cookie_types() );
Expand All @@ -47,19 +47,22 @@ $this->script_loader_tag->add_tag( 'addtoany', $this->get_cookie_types() );

# Cookie Consent Interface

Cookie Consent will return the selected cookie types in PHP. So you can check if the cookie types are selected or not. If the necessary cookie types are selected, you can then skip the code to block the cookies because the consent is already given.
Cookie Consent will return the tracking types which the user has consented to (statistics,marketing etc.). If the necessary cookie types are selected, you can then skip the code to block the cookies because the consent is already given.

For example:
This will check if requested consents are given.
Example:
This will check if required consents are given.
```
if( $this->cookie_consent->are_cookie_states_accepted( $this->get_cookie_types() ) ){
```

# Buffer Output Interface

The Buffer Output is used to manipulate the scripts which are hardcoded inserted. There is no other way to block those cookies then to use buffer output manipulation.
The Buffer Output is used to manipulate the scripts which are hardcoded, and can't be hooked into with default functionality. There is no other way to block those cookies then to use buffer output manipulation.

Example:

This will manipulate the output from wp_footer action hook starting from priority 9 till 11. And it will search for keys given in 3rd parameter(gtag, _gaq, ...). If it does find it then it will apply the cookie types that were selected in the administration UI for the addon at hand. If you don't want to use those types, you can change the parameter into a custom array like this: array('statistics', 'marketing').

For example: This will manipulate the output from wp_footer action hook starting from priority 9 till 11. And it will search for keys given in 3rd parameter(gtag, _gaq, ...). If it does find it then it will apply the cookie types that were selected in the backend. If you don't want to use that types, you can change that into a custom array like this: array('statistics', 'marketing').
```
$this->buffer_output->add_tag( 'wp_footer', 10, array(
'gtag' => $this->get_cookie_types(),
Expand All @@ -73,16 +76,24 @@ $this->buffer_output->add_tag( 'wp_footer', 10, array(

Sometimes you have the option to block the action hook before the hardcoded script. Then you can use remove action to block the cookies.

For example:
Example:
```
remove_action(actionname, functionname);
```

```
if ( has_action( 'wp_head', 'A2A_SHARE_SAVE_head_script' ) ) {
remove_action( 'wp_head', 'A2A_SHARE_SAVE_head_script' );
}
```


# Cookiebot Remove Class Action

Some action hooks are used in a class. The default WordPress doesn't have a feature to remove those action hooks. So we added our own helper function to do that.
Some action hooks are used in a class. By default WordPress doesn't have a feature to remove those action hooks. So we added our own helper function to do that.

Example:

For example:
This will remove the method pixel_init in the class of AEPC_Pixel_Scripts.

- wp_head = action hook
Expand Down

0 comments on commit 3d1484d

Please sign in to comment.