-
Notifications
You must be signed in to change notification settings - Fork 0
/
ctmp-cookieconsent.php
101 lines (89 loc) · 3.21 KB
/
ctmp-cookieconsent.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
/**
* Adds the Cookie Consent library to WordPress to provide Cookie notificatons
*
* @package CTMP_Cookie_Consent
* @author Christoffer T. Timm <[email protected]>
* @license GPL-2.0+
* @link https://github.com/chrim/ctmp-cookieconsent
* @copyright 2016 Christoffer T. Timm
*
* @wordpress-plugin
* Plugin Name: CTMP Cookie Consent
* Plugin URI: https://github.com/chrimm/ctmp-cookieconsent
* Description: Adds the Cookie Consent library to WordPress to provide Cookie notificatons.
* Version: 0.9.5
* Author: Christoffer T. Timm
* Author URI: http://christoffertimm.de
* Text Domain: ctmp-cookieconsent
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Domain Path: /languages
* GitHub Plugin URI: https://github.com/chrimm/ctmp-cookieconsent
* GitHub Branch: master
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2, as
* published by the Free Software Foundation.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* If this file is called directly, abort. */
if ( ! defined( 'ABSPATH' ) ) {
exit();
}
if( ! defined( 'CTMPCC_VER' ) ) {
define( 'CTMPCC_VER', '0.9.5' );
}
if( ! defined( 'COOKIE_CONSENT_VER') ) {
define( 'COOKIE_CONSENT_VER', '1.0.9' );
}
if( ! defined( 'COOKIE_CONSENT_PATH') ) {
define( 'COOKIE_CONSENT_PATH', '//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/'.COOKIE_CONSENT_VER );
}
/*
* Bootstrap
*/
require_once dirname(__FILE__).'/CTMP_Cookie_Consent.class.php';
/*
* Activation Hooks *must* be registered and defined in main file!
*/
register_activation_hook( __FILE__, 'ctmpcc_install' );
register_deactivation_hook( __FILE__, 'ctmpcc_deactivate');
/**
* Creates a new WP Option and writes default configuration to DB
*
* @return void
* @author Christoffer T. Timm <[email protected]>
* @since 0.1.0
*/
function ctmpcc_install() {
/* Set configuration to default */
$default_configuration = CTMP_Cookie_Consent::ctmpcc_default_configuration();
/* Write default settings to DB and register settings */
foreach($default_configuration as $conf_key => $conf_val) {
add_option( CTMPCC_OPTION_PREFIX.$conf_key, $conf_val );
}
}
/**
* Unregisters all settings
*
* @return void
* @author Christoffer T. Timm <[email protected]>
* @since 0.9.1
*/
function ctmpcc_deactivate() {
/* Fetch all setting keys */
$setting_keys = array_keys( CTMP_Cookie_Consent::ctmpcc_default_configuration() );
/* Unregister each settings */
foreach( $setting_keys as $setting_key ) {
unregister_setting( CTMPCC_OPTION_GROUP, CTMPCC_OPTION_PREFIX.setting_key );
}
}
/* Instantiate our Class */
$CTMP_Cookie_Consent = CTMP_Cookie_Consent::ctmpcc_get_instance();