# Aucor Cookie Consent

A simple plugin for displaying a cookie consent notification.

## Install the plugin

1. Download this repository
2. Extract into /plugins/
3. Activate

## How to use

When activated, the plugin displays a notification at the bottom of the screen. By default it displays a *"This website operates using cookies."* message and an *"OK"* confirmation button in a simple box.

### Privacy policy page

The notification can be modified to include a link to a privacy policy page (or anything really). Using the following filter you can include a link to a page using it's ID or a direct URL:

```php
// Set page id for a read more link. You can also use direct URL

add_filter('aucor-cookie-consent-page-id', function($value) {
  return 123; // or 'https://example.url'
});
```
If you absolutely want to, you can also set this in wp-config.php:
```php
define('AUCOR_COOKIE_PAGE_ID', 123);
```
By default the link text is *"Read more"*.

### Polylang support

This plugin supports translations and custom texts through [Polylang](https://wordpress.org/plugins/polylang/). If string translations are given, the plugin will recognise the active language and display the texts in the correct language.

### Custom message

If you don't use Polylang, you can customize the message with the following filter:
```php
// Custom message

add_filter('aucor-cookie-consent-msg', function($value){
  return 'New custom message';
});
```
### Custom confirmation button text
If you don't use Polylang, you can customize the confirmation button text with the following filter:
```php
// Custom button text

add_filter('aucor-cookie-consent-btn', function($value) {
  return 'New custom button text';
});
```

### Custom link text
If you don't use Polylang, you can customize the link text with the following filter:
```php
// Custom read more text

add_filter('aucor-cookie-consent-read-more', function($value){
  return 'New custom link text';
});
```

### Color scheme
The displayed notification has black text with a white background by default. This can be changed to a dark version (white text with a black background) with the following filter:
```php
// Change color scheme, defaults to 'light'. Can be 'light', 'dark' or 'none'

add_filter('aucor-cookie-consent-theme', function($value) {
  return 'dark';
});
```

### Styles
If you aren't satisfied with just a light or dark color scheme, below is the structure of classes (in SASS) of the different components in the notification. The button uses a `.btn` class that your theme might style correctly. Tweak other styles as you need. You can disable all styles with the previous filter and returning 'none'.
```scss
/*********************
Cookie Consent
*********************/

/* Simple */

.cc-banner {
	.cc-message {
		.cc-more-info {

		}
	}
	.cc-btn-wrap {
		.btn {

		}
	}
}

/* All */
.cc-banner{
	&.cc-container {

	}
	&.cc-container--open {

	}
	.cc-container-inner {
		.cc-message-wrap {
			.cc-message {
				.cc-more-info {

				}
			}
		}
		.cc-btn-wrap {
			.btn {

			}
		}
	}
}

```
**Protip:** While the cookie consent notification is visible, the body tag has a "cc-is-visible" class. This can be used to add extra room to the footer etc. if needed.

