-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathwp-consent-api.php
More file actions
151 lines (138 loc) · 3.82 KB
/
wp-consent-api.php
File metadata and controls
151 lines (138 loc) · 3.82 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php // phpcs:ignore WordPress.Files.Filename.InvalidClassFileName
/**
* This file is part of WP Consent API.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 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, see https://www.gnu.org/licenses/.
*
* @package wordpress/consent-api
* @license http://www.gnu.org/licenses/gpl-2.0.html
*
* @wordpress-plugin
* Plugin Name: WP Consent API
* Plugin URI: https://wordpress.org/plugins/wp-consent-api
* Description: Consent Level API to read and register the current consent level for cookie management and improving compliance with privacy laws.
* Version: 2.0.1
* Author: WordPress Contributors
* Author URI: https://github.com/WordPress/wp-consent-level-api
* Requires at least: 5.0
* Requires PHP: 7.4
* License: GPL2+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
// Check that the file is not accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
die( 'We\'re sorry, but you cannot directly access this file.' );
}
if ( ! class_exists( 'WP_Consent_API' ) ) {
/**
* WP_Consent_API class.
*/
class WP_Consent_API {
/**
* Instance.
*
* @since 1.0.0
*
* @var WP_Consent_API|null
*/
private static $instance;
/**
* Config.
*
* @var WP_Consent_API_Config
*/
public static $config;
/**
* Site Health Checks.
*
* @var WP_Consent_API_Site_Health
*/
public static $site_health;
/**
* Cookie info
*
* @var WP_Consent_API_Cookie_Info
*/
public static $cookie_info;
/**
* Instantiate the class.
*
* @since 1.0.0
*
* @return WP_Consent_API
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Initialize the plugin.
*
* @since 1.0.0
*
* @return void
*/
public static function init(): void {
self::get_instance();
}
/**
* Constructor.
*
* @since 1.0.0
*
* @return void
*/
private function __construct() {
$this->setup_constants();
$this->includes();
self::$config = new WP_Consent_API_Config();
self::$site_health = new WP_Consent_API_Site_Health();
self::$cookie_info = new WP_Consent_API_Cookie_Info();
}
/**
* Define Consent API related constants.
*
* @since 1.0.0
*
* @return void
*/
private function setup_constants() {
define( 'WP_CONSENT_API_URL', plugin_dir_url( __FILE__ ) );
define( 'WP_CONSENT_API_PATH', plugin_dir_path( __FILE__ ) );
define( 'WP_CONSENT_API_PLUGIN', plugin_basename( __FILE__ ) );
define( 'WP_CONSENT_API_VERSION', '2.0.1' );
define( 'WP_CONSENT_API_PLUGIN_FILE', __FILE__ );
}
/**
* Include the extra plugin files.
*
* @since 1.0.0
*
* @return void
*/
private function includes() {
require_once WP_CONSENT_API_PATH . 'inc/class-wp-consent-api-config.php';
require_once WP_CONSENT_API_PATH . 'inc/class-wp-consent-api-cookie-info.php';
require_once WP_CONSENT_API_PATH . 'inc/class-wp-consent-api-site-health.php';
require_once WP_CONSENT_API_PATH . 'inc/api-functions.php';
require_once WP_CONSENT_API_PATH . 'inc/wordpress-comments-functions.php';
}
}
/**
* Load the plugins main class.
*/
add_action( 'plugins_loaded', array( WP_Consent_API::class, 'init' ), 9 );
}