WP GDPR Compliance - Version 1.3

Version Description

Release date: May 7th, 2018 * Added the request user data page. You can enable it in the Settings tab. * The newly created page contains a shortcode which allows visitors to request their data. WordPress Users, WordPress Comments and WooCommerce orders linked to their email address are then send to that email address. * The request user data page becomes the delete user page when visited through this email. The link in the email is available for 24 hours (cronjob) and linked to the visitors' IP and current session. * Delete requests end up in the new Requests tab. Click on 'Manage' to view a request and tick the checkbox to anonymise. Make sure to take care of these requests as quickly as possible! * For WordPress Users 'anonymise' means first and last name, display name, nickname and email address are substituted by the corresponding field name in the database. * For WordPress Comments 'anonymise' means author name, email address and IP address are substituted by the corresponding field name in the database. * For WooCommerce orders 'anonymise' means billing and shipping details are substituted by the corresponding field name in the database.

Download this release

Release Info

Developer donnyoexman
Plugin Icon 128x128 WP GDPR Compliance
Version 1.3
Comparing to
See all releases

Code changes from version 1.2.4 to 1.3

Includes/AccessRequest.php ADDED
@@ -0,0 +1,299 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WPGDPRC\Includes;
4
+
5
+ /**
6
+ * Class Requests
7
+ * @package WPGDPRC\Includes
8
+ */
9
+ class AccessRequest {
10
+ /** @var null */
11
+ private static $instance = null;
12
+ /** @var int */
13
+ private $id = 0;
14
+ /** @var int */
15
+ private $siteId = 0;
16
+ /** @var string */
17
+ private $emailAddress = '';
18
+ /** @var string */
19
+ private $sessionId = '';
20
+ /** @var string */
21
+ private $ipAddress = '';
22
+ /** @var int */
23
+ private $expired = 0;
24
+ /** @var string */
25
+ private $dateCreated = '';
26
+
27
+ /**
28
+ * AccessRequest constructor.
29
+ * @param int $id
30
+ */
31
+ public function __construct($id = 0) {
32
+ if ((int)$id > 0) {
33
+ $this->setId($id);
34
+ $this->load();
35
+ }
36
+ }
37
+
38
+ /**
39
+ * @param string $emailAddress
40
+ * @param string $sessionId
41
+ * @return bool|AccessRequest
42
+ */
43
+ public function getByEmailAddressAndSessionId($emailAddress = '', $sessionId = '') {
44
+ global $wpdb;
45
+ $query = "SELECT * FROM `" . self::getDatabaseTableName() . "`
46
+ WHERE `email_address` = '%s'
47
+ AND `session_id` = '%s'
48
+ AND `expired` = '0'";
49
+ $row = $wpdb->get_row($wpdb->prepare($query, $emailAddress, $sessionId));
50
+ if ($row !== null) {
51
+ return new self($row->ID);
52
+ }
53
+ return false;
54
+ }
55
+
56
+ /**
57
+ * @param array $filters
58
+ * @return int
59
+ */
60
+ public function getTotal($filters = array()) {
61
+ global $wpdb;
62
+ $query = "SELECT COUNT(`ID`) FROM `" . self::getDatabaseTableName() . "` WHERE 1";
63
+ $query .= Helper::getQueryByFilters($filters);
64
+ $result = $wpdb->get_var($query);
65
+ if ($result !== null) {
66
+ return absint($result);
67
+ }
68
+ return 0;
69
+ }
70
+
71
+ /**
72
+ * @param array $filters
73
+ * @param int $limit
74
+ * @param int $offset
75
+ * @return AccessRequest[]
76
+ */
77
+ public function getList($filters = array(), $limit = 0, $offset = 0) {
78
+ global $wpdb;
79
+ $output = array();
80
+ $query = "SELECT * FROM `" . self::getDatabaseTableName() . "` WHERE 1";
81
+ $query .= Helper::getQueryByFilters($filters);
82
+ $query .= " ORDER BY `date_created` DESC";
83
+ if (!empty($limit)) {
84
+ $query .= " LIMIT $offset, $limit";
85
+ }
86
+ $results = $wpdb->get_results($query);
87
+ if ($results !== null) {
88
+ foreach ($results as $row) {
89
+ $object = new self;
90
+ $object->loadByRow($row);
91
+ $output[] = $object;
92
+ }
93
+ }
94
+ return $output;
95
+ }
96
+
97
+ /**
98
+ * @param $row
99
+ */
100
+ private function loadByRow($row) {
101
+ $this->setId($row->ID);
102
+ $this->setSiteId($row->site_id);
103
+ $this->setEmailAddress($row->email_address);
104
+ $this->setSessionId($row->session_id);
105
+ $this->setIpAddress($row->ip_address);
106
+ $this->setExpired($row->expired);
107
+ $this->setDateCreated($row->date_created);
108
+ }
109
+
110
+ public function load() {
111
+ global $wpdb;
112
+ $query = "SELECT * FROM `" . self::getDatabaseTableName() . "` WHERE `ID` = '%d'";
113
+ $row = $wpdb->get_row($wpdb->prepare($query, $this->getId()));
114
+ if ($row !== null) {
115
+ $this->loadByRow($row);
116
+ }
117
+ }
118
+
119
+ /**
120
+ * @param int $id
121
+ * @return bool
122
+ */
123
+ public function exists($id = 0) {
124
+ global $wpdb;
125
+ $row = $wpdb->get_row(
126
+ $wpdb->prepare(
127
+ "SELECT * FROM `" . self::getDatabaseTableName() . "` WHERE `ID` = '%d'",
128
+ intval($id)
129
+ )
130
+ );
131
+ return ($row !== null);
132
+ }
133
+
134
+ /**
135
+ * @param string $emailAddress
136
+ * @param bool $nonExpiredOnly
137
+ * @return bool
138
+ */
139
+ public function existsByEmailAddress($emailAddress = '', $nonExpiredOnly = false) {
140
+ global $wpdb;
141
+ $query = "SELECT * FROM `" . self::getDatabaseTableName() . "` WHERE `email_address` = '%s'";
142
+ if ($nonExpiredOnly) {
143
+ $query .= " AND `expired` = '0'";
144
+ }
145
+ $row = $wpdb->get_row($wpdb->prepare($query, $emailAddress));
146
+ return ($row !== null);
147
+ }
148
+
149
+ /**
150
+ * @return bool|int
151
+ */
152
+ public function save() {
153
+ global $wpdb;
154
+ if ($this->exists($this->getId())) {
155
+ $wpdb->update(
156
+ self::getDatabaseTableName(),
157
+ array('expired' => $this->getExpired()),
158
+ array('ID' => $this->getId()),
159
+ array('%d'),
160
+ array('%d')
161
+ );
162
+ return $this->getId();
163
+ } else {
164
+ $result = $wpdb->insert(
165
+ self::getDatabaseTableName(),
166
+ array(
167
+ 'site_id' => $this->getSiteId(),
168
+ 'email_address' => $this->getEmailAddress(),
169
+ 'session_id' => $this->getSessionId(),
170
+ 'ip_address' => $this->getIpAddress(),
171
+ 'expired' => $this->getExpired(),
172
+ 'date_created' => date_i18n('Y-m-d H:i:s'),
173
+ ),
174
+ array('%d', '%s', '%s', '%s', '%d', '%s')
175
+ );
176
+ if ($result !== false) {
177
+ $this->setId($wpdb->insert_id);
178
+ return $this->getId();
179
+ }
180
+ }
181
+ return false;
182
+ }
183
+
184
+ /**
185
+ * @return null|AccessRequest
186
+ */
187
+ public static function getInstance() {
188
+ if (!isset(self::$instance)) {
189
+ self::$instance = new self();
190
+ }
191
+ return self::$instance;
192
+ }
193
+
194
+ /**
195
+ * @return int
196
+ */
197
+ public function getId() {
198
+ return $this->id;
199
+ }
200
+
201
+ /**
202
+ * @param int $id
203
+ */
204
+ public function setId($id) {
205
+ $this->id = $id;
206
+ }
207
+
208
+ /**
209
+ * @return int
210
+ */
211
+ public function getSiteId() {
212
+ return $this->siteId;
213
+ }
214
+
215
+ /**
216
+ * @param int $siteId
217
+ */
218
+ public function setSiteId($siteId) {
219
+ $this->siteId = $siteId;
220
+ }
221
+
222
+ /**
223
+ * @return string
224
+ */
225
+ public function getEmailAddress() {
226
+ return $this->emailAddress;
227
+ }
228
+
229
+ /**
230
+ * @param string $emailAddress
231
+ */
232
+ public function setEmailAddress($emailAddress) {
233
+ $this->emailAddress = $emailAddress;
234
+ }
235
+
236
+ /**
237
+ * @return string
238
+ */
239
+ public function getSessionId() {
240
+ return $this->sessionId;
241
+ }
242
+
243
+ /**
244
+ * @param string $sessionId
245
+ */
246
+ public function setSessionId($sessionId) {
247
+ $this->sessionId = $sessionId;
248
+ }
249
+
250
+ /**
251
+ * @return string
252
+ */
253
+ public function getIpAddress() {
254
+ return $this->ipAddress;
255
+ }
256
+
257
+ /**
258
+ * @param string $ipAddress
259
+ */
260
+ public function setIpAddress($ipAddress) {
261
+ $this->ipAddress = $ipAddress;
262
+ }
263
+
264
+ /**
265
+ * @return int
266
+ */
267
+ public function getExpired() {
268
+ return $this->expired;
269
+ }
270
+
271
+ /**
272
+ * @param int $expired
273
+ */
274
+ public function setExpired($expired) {
275
+ $this->expired = $expired;
276
+ }
277
+
278
+ /**
279
+ * @return string
280
+ */
281
+ public function getDateCreated() {
282
+ return $this->dateCreated;
283
+ }
284
+
285
+ /**
286
+ * @param string $dateCreated
287
+ */
288
+ public function setDateCreated($dateCreated) {
289
+ $this->dateCreated = $dateCreated;
290
+ }
291
+
292
+ /**
293
+ * @return string
294
+ */
295
+ public static function getDatabaseTableName() {
296
+ global $wpdb;
297
+ return $wpdb->base_prefix . 'wpgdprc_access_requests';
298
+ }
299
+ }
Includes/Action.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WPGDPRC\Includes;
4
+
5
+ /**
6
+ * Class Action
7
+ * @package WPGDPRC\Includes
8
+ */
9
+ class Action {
10
+ /** @var null */
11
+ private static $instance = null;
12
+
13
+ /**
14
+ * Stop WordPress from sending anything but essential data during the update check
15
+ * @param array $query
16
+ * @return array
17
+ */
18
+ public function onlySendEssentialDataDuringUpdateCheck($query = array()) {
19
+ unset($query['php']);
20
+ unset($query['mysql']);
21
+ unset($query['local_package']);
22
+ unset($query['blogs']);
23
+ unset($query['users']);
24
+ unset($query['multisite_enabled']);
25
+ unset($query['initial_db_version']);
26
+ return $query;
27
+ }
28
+
29
+ public function processEnableAccessRequest() {
30
+ $page = Helper::getAccessRequestPage();
31
+ $enabled = Helper::isEnabled('enable_access_request', 'settings');
32
+ $status = ($enabled) ? 'private' : 'draft';
33
+ if ($enabled && $page === false) {
34
+ $result = wp_insert_post(array(
35
+ 'post_type' => 'page',
36
+ 'post_status' => $status,
37
+ 'post_title' => __('Data Access Request', WP_GDPR_C_SLUG),
38
+ 'post_content' => '[wpgdprc_access_request_form]',
39
+ 'meta_input' => array(
40
+ '_wpgdprc_access_request' => 1,
41
+ ),
42
+ ), true);
43
+ if (!is_wp_error($result)) {
44
+ $page = get_post($result);
45
+ }
46
+ }
47
+ if (!empty($page)) {
48
+ wp_update_post(array(
49
+ 'ID' => $page->ID,
50
+ 'post_status' => $status
51
+ ));
52
+ }
53
+ if ($enabled) {
54
+ global $wpdb;
55
+ require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
56
+ $charsetCollate = $wpdb->get_charset_collate();
57
+ $sql = "CREATE TABLE IF NOT EXISTS `" . AccessRequest::getDatabaseTableName() . "` (
58
+ `ID` bigint(20) NOT NULL AUTO_INCREMENT,
59
+ `site_id` bigint(20) NOT NULL,
60
+ `email_address` varchar(100) NOT NULL,
61
+ `session_id` varchar(255) NOT NULL,
62
+ `ip_address` varchar(100) NOT NULL,
63
+ `expired` tinyint(1) DEFAULT '0' NOT NULL,
64
+ `date_created` datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
65
+ PRIMARY KEY (`ID`)
66
+ ) $charsetCollate;";
67
+ dbDelta($sql);
68
+ $sql = "CREATE TABLE IF NOT EXISTS `" . DeleteRequest::getDatabaseTableName() . "` (
69
+ `ID` bigint(20) NOT NULL AUTO_INCREMENT,
70
+ `site_id` bigint(20) NOT NULL,
71
+ `access_request_id` bigint(20) NOT NULL,
72
+ `session_id` varchar(255) NOT NULL,
73
+ `ip_address` varchar(100) NOT NULL,
74
+ `data_id` bigint(20) NOT NULL,
75
+ `type` varchar(255) NOT NULL,
76
+ `processed` tinyint(1) DEFAULT '0' NOT NULL,
77
+ `date_created` datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
78
+ PRIMARY KEY (`ID`)
79
+ ) $charsetCollate;";
80
+ dbDelta($sql);
81
+ }
82
+ }
83
+
84
+ /**
85
+ * @return null|Action
86
+ */
87
+ public static function getInstance() {
88
+ if (!isset(self::$instance)) {
89
+ self::$instance = new self();
90
+ }
91
+ return self::$instance;
92
+ }
93
+ }
Includes/Actions.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
-
3
- namespace WPGDPRC\Includes;
4
-
5
- /**
6
- * Class Actions
7
- * @package WPGDPRC\Includes
8
- */
9
- class Actions {
10
- /** @var null */
11
- private static $instance = null;
12
-
13
- /**
14
- * Stop WordPress from sending anything but essential data during the update check
15
- * @param array $query
16
- * @return array
17
- */
18
- public function onlySendEssentialDataDuringUpdateCheck($query = array()) {
19
- unset($query['php']);
20
- unset($query['mysql']);
21
- unset($query['local_package']);
22
- unset($query['blogs']);
23
- unset($query['users']);
24
- unset($query['multisite_enabled']);
25
- unset($query['initial_db_version']);
26
- return $query;
27
- }
28
-
29
- /**
30
- * @return null|Actions
31
- */
32
- public static function getInstance() {
33
- if (!isset(self::$instance)) {
34
- self::$instance = new self();
35
- }
36
- return self::$instance;
37
- }
38
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Includes/Ajax.php CHANGED
@@ -14,8 +14,8 @@ class Ajax {
14
  check_ajax_referer('wpgdprc', 'security');
15
 
16
  $output = array(
 
17
  'error' => '',
18
- 'redirect' => false
19
  );
20
  $data = (isset($_POST['data']) && (is_array($_POST['data']) || is_string($_POST['data']))) ? $_POST['data'] : false;
21
  if (is_string($data)) {
@@ -71,6 +71,239 @@ class Ajax {
71
  do_action($option, $value);
72
  }
73
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  }
75
  }
76
 
14
  check_ajax_referer('wpgdprc', 'security');
15
 
16
  $output = array(
17
+ 'message' => '',
18
  'error' => '',
 
19
  );
20
  $data = (isset($_POST['data']) && (is_array($_POST['data']) || is_string($_POST['data']))) ? $_POST['data'] : false;
21
  if (is_string($data)) {
71
  do_action($option, $value);
72
  }
73
  break;
74
+ case 'access_request' :
75
+ if (Helper::isEnabled('enable_access_request', 'settings')) {
76
+ $emailAddress = (isset($data['email']) && is_email($data['email'])) ? $data['email'] : false;
77
+ $consent = (isset($data['consent'])) ? filter_var($data['consent'], FILTER_VALIDATE_BOOLEAN) : false;
78
+
79
+ if (!$emailAddress) {
80
+ $output['error'] = __('Missing or incorrect email address.', WP_GDPR_C_SLUG);
81
+ }
82
+
83
+ if (!$consent) {
84
+ $output['error'] = __('You need to accept the privacy checkbox.', WP_GDPR_C_SLUG);
85
+ }
86
+
87
+ // Let's do this!
88
+ if (empty($output['error'])) {
89
+ if (!AccessRequest::getInstance()->existsByEmailAddress($emailAddress, true)) {
90
+ $request = new AccessRequest();
91
+ $request->setSiteId(get_current_blog_id());
92
+ $request->setEmailAddress($emailAddress);
93
+ $request->setSessionId(SessionHelper::getSessionId());
94
+ $request->setIpAddress(Helper::getClientIpAddress());
95
+ $request->setExpired(0);
96
+ $id = $request->save();
97
+ if ($id !== false) {
98
+ $page = Helper::getAccessRequestPage();
99
+ if (!empty($page)) {
100
+ if (is_multisite()) {
101
+ $siteName = get_blog_option($request->getSiteId(), 'blogname');
102
+ $siteEmail = get_blog_option($request->getSiteId(), 'admin_email');
103
+ $siteUrl = get_blog_option($request->getSiteId(), 'siteurl');
104
+ } else {
105
+ $siteName = get_option('blogname');
106
+ $siteEmail = get_option('admin_email');
107
+ $siteUrl = get_option('siteurl');
108
+ }
109
+ $subject = sprintf(__('%s - Your data request', WP_GDPR_C_SLUG), $siteName);
110
+ $message = sprintf(
111
+ __('You have requested to access your data on %s.', WP_GDPR_C_SLUG),
112
+ sprintf('<a target="_blank" href="%s">%s</a>', $siteUrl, $siteName)
113
+ ) . '<br /><br />';
114
+ $message .= sprintf(
115
+ __('Please visit this %s to view the data linked to the email address %s', WP_GDPR_C_SLUG),
116
+ sprintf(
117
+ '<a target="_blank" href="%s">%s</a>',
118
+ add_query_arg(
119
+ array(
120
+ 'wpgdprc' => base64_encode(serialize(array(
121
+ 'email' => $request->getEmailAddress(),
122
+ 'sId' => $request->getSessionId()
123
+ )))
124
+ ),
125
+ get_permalink($page)
126
+ ),
127
+ __('page', WP_GDPR_C_SLUG)
128
+ ),
129
+ $emailAddress
130
+ ) . '<br /><br />';
131
+ $message .= __('This page is available for 24 hours and can only be reached from the same IP address you requested from.', WP_GDPR_C_SLUG) . '<br />';
132
+ $message .= sprintf(
133
+ __('If your link is invalid please fill in a new request: %s.', WP_GDPR_C_SLUG),
134
+ sprintf('<a target="_blank" href="%s">%s</a>', get_permalink($page), get_the_title($page))
135
+ );
136
+ $headers = array(
137
+ 'Content-Type: text/html; charset=UTF-8',
138
+ "From: $siteName <$siteEmail>"
139
+ );
140
+ $response = wp_mail($emailAddress, $subject, $message, $headers);
141
+ if ($response !== false) {
142
+ $output['message'] = __('Success. You will receive an email with your data shortly.', WP_GDPR_C_SLUG);
143
+ }
144
+ }
145
+ } else {
146
+ $output['error'] = __('Something went wrong while saving the request.', WP_GDPR_C_SLUG);
147
+ }
148
+ } else {
149
+ $output['error'] = __('You have already requested your data. Please check your mailbox. After 24 hours you can put in a new request.', WP_GDPR_C_SLUG);
150
+ }
151
+ }
152
+ }
153
+ break;
154
+ case 'delete_request' :
155
+ if (Helper::isEnabled('enable_access_request', 'settings')) {
156
+ $session = (isset($data['session'])) ? esc_html($data['session']) : '';
157
+ $settings = (isset($data['settings']) && is_array($data['settings'])) ? $data['settings'] : array();
158
+ $type = (isset($settings['type']) && in_array($settings['type'], Data::getPossibleDataTypes())) ? $settings['type'] : '';
159
+ $value = (isset($data['value']) && is_numeric($data['value'])) ? (int)$data['value'] : 0;
160
+
161
+ if (empty($session)) {
162
+ $output['error'] = __('Missing session.', WP_GDPR_C_SLUG);
163
+ }
164
+
165
+ if (empty($type)) {
166
+ $output['error'] = __('Missing or invalid type.', WP_GDPR_C_SLUG);
167
+ }
168
+
169
+ if ($value === 0) {
170
+ $output['error'] = __('No value selected.', WP_GDPR_C_SLUG);
171
+ }
172
+
173
+ // Let's do this!
174
+ if (empty($output['error'])) {
175
+ $accessRequest = unserialize(base64_decode($session));
176
+ $accessRequest = (!empty($accessRequest)) ? AccessRequest::getInstance()->getByEmailAddressAndSessionId($accessRequest['email'], $accessRequest['sId']) : false;
177
+ if ($accessRequest !== false) {
178
+ if (
179
+ SessionHelper::checkSession($accessRequest->getSessionId()) &&
180
+ Helper::checkIpAddress($accessRequest->getIpAddress())
181
+ ) {
182
+ $request = new DeleteRequest();
183
+ $request->setSiteId(get_current_blog_id());
184
+ $request->setAccessRequestId($accessRequest->getId());
185
+ $request->setSessionId($accessRequest->getSessionId());
186
+ $request->setIpAddress($accessRequest->getIpAddress());
187
+ $request->setDataId($value);
188
+ $request->setType($type);
189
+ $id = $request->save();
190
+ if ($id === false) {
191
+ $output['error'] = __('Something went wrong while saving this request. Please try again.', WP_GDPR_C_SLUG);
192
+ }
193
+ } else {
194
+ $output['error'] = __('Session doesn\'t match.', WP_GDPR_C_SLUG);
195
+ }
196
+ } else {
197
+ $output['error'] = __('No session found.', WP_GDPR_C_SLUG);
198
+ }
199
+ }
200
+ }
201
+ break;
202
+ }
203
+ }
204
+
205
+ header('Content-type: application/json');
206
+ echo json_encode($output);
207
+ die();
208
+ }
209
+
210
+ public function processDeleteRequest() {
211
+ check_ajax_referer('wpgdprc', 'security');
212
+
213
+ $output = array(
214
+ 'message' => '',
215
+ 'error' => '',
216
+ );
217
+
218
+ if (!Helper::isEnabled('enable_access_request', 'settings')) {
219
+ $output['error'] = __('The access request functionality is not enabled.', WP_GDPR_C_SLUG);
220
+ }
221
+
222
+ $data = (isset($_POST['data']) && (is_array($_POST['data']) || is_string($_POST['data']))) ? $_POST['data'] : false;
223
+ if (is_string($data)) {
224
+ $data = json_decode(stripslashes($data), true);
225
+ }
226
+ $id = (isset($data['id']) && is_numeric($data['id'])) ? absint($data['id']) : 0;
227
+
228
+ if (!$data) {
229
+ $output['error'] = __('Missing data.', WP_GDPR_C_SLUG);
230
+ }
231
+
232
+ if ($id === 0 || !DeleteRequest::getInstance()->exists($id)) {
233
+ $output['error'] = __('This delete request doesn\'t exist.', WP_GDPR_C_SLUG);
234
+ }
235
+
236
+ // Let's do this!
237
+ if (empty($output['error'])) {
238
+ $request = new DeleteRequest($id);
239
+ if (!$request->getProcessed()) {
240
+ switch ($request->getType()) {
241
+ case 'user' :
242
+ if (current_user_can('edit_users')) {
243
+ $date = Helper::localDateTime(time());
244
+ $result = wp_update_user(array(
245
+ 'ID' => $request->getDataId(),
246
+ 'display_name' => 'DISPLAY_NAME',
247
+ 'nickname' => 'NICKNAME',
248
+ 'first_name' => 'FIRST_NAME',
249
+ 'last_name' => 'LAST_NAME',
250
+ 'user_email' => $request->getDataId() . '.' . $date->format('Ymd') . '.' . $date->format('His') . '@example.org'
251
+ ));
252
+ if (is_wp_error($result)) {
253
+ $output['error'] = __('This user doesn\'t exist.', WP_GDPR_C_SLUG);
254
+ } else {
255
+ $request->setProcessed(1);
256
+ $request->save();
257
+ }
258
+ } else {
259
+ $output['error'] = __('You\'re not allowed to edit users.', WP_GDPR_C_SLUG);
260
+ }
261
+ break;
262
+ case 'comment' :
263
+ if (current_user_can('edit_posts')) {
264
+ $date = Helper::localDateTime(time());
265
+ $result = wp_update_comment(array(
266
+ 'comment_ID' => $request->getDataId(),
267
+ 'comment_author' => 'NAME',
268
+ 'comment_author_email' => $request->getDataId() . '.' . $date->format('Ymd') . '.' . $date->format('His') . '@example.org',
269
+ 'comment_author_IP' => '127.0.0.1'
270
+ ));
271
+ if ($result === 0) {
272
+ $output['error'] = __('This comment doesn\'t exist.', WP_GDPR_C_SLUG);
273
+ } else {
274
+ $request->setProcessed(1);
275
+ $request->save();
276
+ }
277
+ } else {
278
+ $output['error'] = __('You\'re not allowed to edit comments.', WP_GDPR_C_SLUG);
279
+ }
280
+ break;
281
+ case 'woocommerce_order' :
282
+ if (current_user_can('edit_shop_orders')) {
283
+ $date = Helper::localDateTime(time());
284
+ update_post_meta($request->getDataId(), '_billing_first_name', 'FIRST_NAME');
285
+ update_post_meta($request->getDataId(), '_billing_last_name', 'LAST_NAME');
286
+ update_post_meta($request->getDataId(), '_billing_company', 'COMPANY_NAME');
287
+ update_post_meta($request->getDataId(), '_billing_address_1', 'ADDRESS_1');
288
+ update_post_meta($request->getDataId(), '_billing_address_2', 'ADDRESS_2');
289
+ update_post_meta($request->getDataId(), '_billing_postcode', 'ZIP_CODE');
290
+ update_post_meta($request->getDataId(), '_billing_city', 'CITY');
291
+ update_post_meta($request->getDataId(), '_billing_phone', 'PHONE_NUMBER');
292
+ update_post_meta($request->getDataId(), '_billing_email', $request->getDataId() . '.' . $date->format('Ymd') . '.' . $date->format('His') . '@example.org');
293
+ update_post_meta($request->getDataId(), '_shipping_first_name', 'FIRST_NAME');
294
+ update_post_meta($request->getDataId(), '_shipping_last_name', 'LAST_NAME');
295
+ update_post_meta($request->getDataId(), '_shipping_company', 'COMPANY_NAME');
296
+ update_post_meta($request->getDataId(), '_shipping_address_1', 'ADDRESS_1');
297
+ update_post_meta($request->getDataId(), '_shipping_address_2', 'ADDRESS_2');
298
+ update_post_meta($request->getDataId(), '_shipping_postcode', 'ZIP_CODE');
299
+ update_post_meta($request->getDataId(), '_shipping_city', 'CITY');
300
+ } else {
301
+ $output['error'] = __('You\'re not allowed to edit WooCommerce orders.', WP_GDPR_C_SLUG);
302
+ }
303
+ break;
304
+ }
305
+ } else {
306
+ $output['error'] = __('This delete request has already been processed.', WP_GDPR_C_SLUG);
307
  }
308
  }
309
 
Includes/Cron.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WPGDPRC\Includes;
4
+
5
+ /**
6
+ * Class Cron
7
+ * @package WPGDPRC\Includes
8
+ */
9
+ class Cron {
10
+ /** @var null */
11
+ private static $instance = null;
12
+
13
+ /**
14
+ * Deactivate requests after 24 hours
15
+ */
16
+ public function deactivateAccessRequests() {
17
+ $date = Helper::localDateTime(time());
18
+ $date->modify('-24 hours');
19
+ $requests = AccessRequest::getInstance()->getList(array(
20
+ 'expired' => array(
21
+ 'value' => 0
22
+ ),
23
+ 'date_created' => array(
24
+ 'value' => $date->format('Y-m-d H:i:s'),
25
+ 'compare' => '<='
26
+ ),
27
+ ));
28
+ if (!empty($requests)) {
29
+ foreach ($requests as $request) {
30
+ $request->setExpired(1);
31
+ $request->save();
32
+ }
33
+ }
34
+ }
35
+
36
+ /**
37
+ * @return null|Cron
38
+ */
39
+ public static function getInstance() {
40
+ if (!isset(self::$instance)) {
41
+ self::$instance = new self();
42
+ }
43
+ return self::$instance;
44
+ }
45
+ }
Includes/Data.php ADDED
@@ -0,0 +1,256 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WPGDPRC\Includes;
4
+
5
+ use WPGDPRC\Includes\Data\Comment;
6
+ use WPGDPRC\Includes\Data\User;
7
+ use WPGDPRC\Includes\Data\WooCommerceOrder;
8
+
9
+ /**
10
+ * Class Data
11
+ * @package WPGDPRC\Includes
12
+ */
13
+ class Data {
14
+ /** @var null */
15
+ private static $instance = null;
16
+ /** @var string */
17
+ protected $emailAddress = '';
18
+
19
+ /**
20
+ * Data constructor.
21
+ * @param string $emailAddress
22
+ */
23
+ public function __construct($emailAddress = '') {
24
+ if (empty($emailAddress)) {
25
+ wp_die(
26
+ '<p>' . sprintf(
27
+ __('<strong>ERROR</strong>: %s', WP_GDPR_C_SLUG),
28
+ __('Email Address is required.', WP_GDPR_C_SLUG)
29
+ ) . '</p>'
30
+ );
31
+ exit;
32
+ }
33
+ $this->setEmailAddress($emailAddress);
34
+ }
35
+
36
+ /**
37
+ * @return array
38
+ */
39
+ public static function getPossibleDataTypes() {
40
+ return array('user', 'comment', 'woocommerce_order');
41
+ }
42
+
43
+ /**
44
+ * @param string $type
45
+ * @return array
46
+ */
47
+ private static function getOutputColumns($type = '') {
48
+ $output = array();
49
+ switch ($type) {
50
+ case 'user' :
51
+ $output = array(
52
+ __('Username', WP_GDPR_C_SLUG),
53
+ __('Display Name', WP_GDPR_C_SLUG),
54
+ __('Email Address', WP_GDPR_C_SLUG),
55
+ __('Website', WP_GDPR_C_SLUG),
56
+ __('Registered on', WP_GDPR_C_SLUG)
57
+ );
58
+ break;
59
+ case 'comment' :
60
+ $output = array(
61
+ __('Author', WP_GDPR_C_SLUG),
62
+ __('Content', WP_GDPR_C_SLUG),
63
+ __('Email Address', WP_GDPR_C_SLUG),
64
+ __('IP Address', WP_GDPR_C_SLUG)
65
+ );
66
+ break;
67
+ case 'woocommerce_order' :
68
+ $output = array(
69
+ __('Order', WP_GDPR_C_SLUG),
70
+ __('Email Address', WP_GDPR_C_SLUG),
71
+ __('Name', WP_GDPR_C_SLUG),
72
+ __('Address', WP_GDPR_C_SLUG),
73
+ __('Postcode / ZIP', WP_GDPR_C_SLUG),
74
+ __('City', WP_GDPR_C_SLUG)
75
+ );
76
+ break;
77
+ }
78
+ $output[] = '<input type="checkbox" class="wpgdprc-select-all" />';
79
+ return $output;
80
+ }
81
+
82
+ /**
83
+ * @param array $data
84
+ * @param string $type
85
+ * @param int $requestId
86
+ * @return array
87
+ */
88
+ private static function getOutputData($data = array(), $type = '', $requestId = 0) {
89
+ $output = array();
90
+ $action = '<input type="checkbox" name="' . WP_GDPR_C_PREFIX . '_remove[]" class="wpgdprc-checkbox" value="%d" tabindex="1" />';
91
+ switch ($type) {
92
+ case 'user' :
93
+ /** @var User $user */
94
+ foreach ($data as $user) {
95
+ $request = DeleteRequest::getInstance()->getByTypeAndDataIdAndAccessRequestId($type, $user->getId(), $requestId);
96
+ $output[$user->getId()] = array(
97
+ $user->getUsername(),
98
+ $user->getDisplayName(),
99
+ $user->getEmailAddress(),
100
+ $user->getWebsite(),
101
+ $user->getRegisteredDate(),
102
+ (($request === false) ? sprintf($action, $user->getId()) : '&nbsp;')
103
+ );
104
+ }
105
+ break;
106
+ case 'comment' :
107
+ /** @var Comment $comment */
108
+ foreach ($data as $comment) {
109
+ $request = DeleteRequest::getInstance()->getByTypeAndDataIdAndAccessRequestId($type, $comment->getId(), $requestId);
110
+ $output[$comment->getId()] = array(
111
+ $comment->getAuthorName(),
112
+ Helper::shortenStringByWords(wp_strip_all_tags($comment->getContent(), true), 5),
113
+ $comment->getEmailAddress(),
114
+ $comment->getIpAddress(),
115
+ (($request === false) ? sprintf($action, $comment->getId()) : '&nbsp;')
116
+ );
117
+ }
118
+ break;
119
+ case 'woocommerce_order' :
120
+ /** @var WooCommerceOrder $woocommerceOrder */
121
+ foreach ($data as $woocommerceOrder) {
122
+ $request = DeleteRequest::getInstance()->getByTypeAndDataIdAndAccessRequestId($type, $woocommerceOrder->getOrderId(), $requestId);
123
+ $address = (!empty($woocommerceOrder->getBillingAddressTwo())) ? sprintf('%s,<br />%s', $woocommerceOrder->getBillingAddressOne(), $woocommerceOrder->getBillingAddressTwo()) : $woocommerceOrder->getBillingAddressOne();
124
+ $output[$woocommerceOrder->getOrderId()] = array(
125
+ sprintf('#%d', $woocommerceOrder->getOrderId()),
126
+ $woocommerceOrder->getBillingEmailAddress(),
127
+ sprintf('%s %s', $woocommerceOrder->getBillingFirstName(), $woocommerceOrder->getBillingLastName()),
128
+ $address,
129
+ $woocommerceOrder->getBillingPostCode(),
130
+ $woocommerceOrder->getBillingCity(),
131
+ (($request === false) ? sprintf($action, $woocommerceOrder->getOrderId()) : '&nbsp;')
132
+ );
133
+ }
134
+ break;
135
+ }
136
+ return $output;
137
+ }
138
+
139
+ /**
140
+ * @param array $data
141
+ * @param string $type
142
+ * @param int $requestId
143
+ * @return string
144
+ */
145
+ public static function getOutput($data = array(), $type = '', $requestId = 0) {
146
+ $output = '';
147
+ if (!empty($data)) {
148
+ $output .= sprintf(
149
+ '<form class="wpgdprc-form wpgdprc-form--delete-request" data-wpgdprc=\'%s\' method="POST" novalidate="novalidate">',
150
+ json_encode(array(
151
+ 'type' => $type
152
+ ))
153
+ );
154
+ $output .= '<div class="wpgdprc-feedback" style="display: none;"></div>';
155
+ $output .= '<table class="wpgdprc-table">';
156
+ $output .= '<thead>';
157
+ $output .= '<tr>';
158
+ foreach (self::getOutputColumns($type) as $column) {
159
+ $output .= sprintf('<th scope="col">%s</th>', $column);
160
+ }
161
+ $output .= '</tr>';
162
+ $output .= '</thead>';
163
+ $output .= '<tbody>';
164
+ foreach (self::getOutputData($data, $type, $requestId) as $id => $row) {
165
+ $output .= sprintf('<tr data-id="%d">', $id);
166
+ foreach ($row as $value) {
167
+ $output .= sprintf('<td>%s</td>', $value);
168
+ }
169
+ $output .= '</tr>';
170
+ }
171
+ $output .= '</tbody>';
172
+ $output .= '</table>';
173
+ $output .= sprintf(
174
+ '<p><input type="submit" class="wpgdprc-remove" value="Remove selected %s(s)" /></p>',
175
+ str_replace('_', ' ', $type)
176
+ );
177
+ $output .= '</form>';
178
+ }
179
+ return $output;
180
+ }
181
+
182
+ /**
183
+ * @return User[]
184
+ */
185
+ public function getUsers() {
186
+ global $wpdb;
187
+ $output = array();
188
+ $query = "SELECT * FROM `" . $wpdb->users . "` WHERE `user_email` = '%s'";
189
+ $results = $wpdb->get_results($wpdb->prepare($query, $this->getEmailAddress()));
190
+ if ($results !== null) {
191
+ foreach ($results as $row) {
192
+ $object = new User($row->ID);
193
+ $output[] = $object;
194
+ }
195
+ }
196
+ return $output;
197
+ }
198
+
199
+ /**
200
+ * @return Comment[]
201
+ */
202
+ public function getComments() {
203
+ global $wpdb;
204
+ $output = array();
205
+ $query = "SELECT * FROM " . $wpdb->comments . " WHERE `comment_author_email` = '%s'";
206
+ $results = $wpdb->get_results($wpdb->prepare($query, $this->getEmailAddress()));
207
+ if ($results !== null) {
208
+ foreach ($results as $row) {
209
+ $object = new Comment();
210
+ $object->loadByRow($row);
211
+ $output[] = $object;
212
+ }
213
+ }
214
+ return $output;
215
+ }
216
+
217
+ /**
218
+ * @return WooCommerceOrder[]
219
+ */
220
+ public function getWooCommerceOrders() {
221
+ global $wpdb;
222
+ $output = array();
223
+ $query = "SELECT * FROM " . $wpdb->postmeta . " WHERE `meta_key` = '_billing_email' AND `meta_value` = '%s'";
224
+ $results = $wpdb->get_results($wpdb->prepare($query, $this->getEmailAddress()));
225
+ if ($results !== null) {
226
+ foreach ($results as $row) {
227
+ $output[] = new WooCommerceOrder($row->post_id);
228
+ }
229
+ }
230
+ return $output;
231
+ }
232
+
233
+ /**
234
+ * @return string
235
+ */
236
+ public function getEmailAddress() {
237
+ return $this->emailAddress;
238
+ }
239
+
240
+ /**
241
+ * @param string $emailAddress
242
+ */
243
+ public function setEmailAddress($emailAddress) {
244
+ $this->emailAddress = $emailAddress;
245
+ }
246
+
247
+ /**
248
+ * @return null|Data
249
+ */
250
+ public static function getInstance() {
251
+ if (!isset(self::$instance)) {
252
+ self::$instance = new self();
253
+ }
254
+ return self::$instance;
255
+ }
256
+ }
Includes/Data/Comment.php ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WPGDPRC\Includes\Data;
4
+
5
+ /**
6
+ * Class Comment
7
+ * @package WPGDPRC\Includes\Data
8
+ */
9
+ class Comment {
10
+ /** @var null */
11
+ private static $instance = null;
12
+ /** @var int */
13
+ protected $id = 0;
14
+ /** @var int */
15
+ protected $postId = 0;
16
+ /** @var string */
17
+ protected $name = '';
18
+ /** @var string */
19
+ protected $emailAddress = '';
20
+ /** @var string */
21
+ protected $content = '';
22
+ /** @var string */
23
+ protected $ipAddress = '';
24
+ /** @var string */
25
+ protected $date = '';
26
+
27
+ /**
28
+ * Comment constructor.
29
+ * @param int $id
30
+ */
31
+ public function __construct($id = 0) {
32
+ if ((int)$id > 0) {
33
+ $this->setId($id);
34
+ $this->load();
35
+ }
36
+ }
37
+
38
+ public function load() {
39
+ global $wpdb;
40
+ $query = "SELECT * FROM `" . $wpdb->users . "` WHERE `ID` = '%d'";
41
+ $row = $wpdb->get_row($wpdb->prepare($query, $this->getId()));
42
+ if ($row !== null) {
43
+ $this->loadByRow($row);
44
+ }
45
+ }
46
+
47
+ /**
48
+ * @param \stdClass $row
49
+ */
50
+ public function loadByRow(\stdClass $row) {
51
+ $this->setId($row->comment_ID);
52
+ $this->setPostId($row->comment_post_ID);
53
+ $this->setName($row->comment_author);
54
+ $this->setEmailAddress($row->comment_author_email);
55
+ $this->setIpAddress($row->comment_author_IP);
56
+ $this->setContent($row->comment_content);
57
+ $this->setDate($row->comment_date);
58
+ }
59
+
60
+ /**
61
+ * @return null|Comment
62
+ */
63
+ public static function getInstance() {
64
+ if (!isset(self::$instance)) {
65
+ self::$instance = new self();
66
+ }
67
+ return self::$instance;
68
+ }
69
+
70
+ /**
71
+ * @return int
72
+ */
73
+ public function getId() {
74
+ return $this->id;
75
+ }
76
+
77
+ /**
78
+ * @param int $id
79
+ */
80
+ public function setId($id) {
81
+ $this->id = $id;
82
+ }
83
+
84
+ /**
85
+ * @return int
86
+ */
87
+ public function getPostId() {
88
+ return $this->postId;
89
+ }
90
+
91
+ /**
92
+ * @param int $postId
93
+ */
94
+ public function setPostId($postId) {
95
+ $this->postId = $postId;
96
+ }
97
+
98
+ /**
99
+ * @return string
100
+ */
101
+ public function getAuthorName() {
102
+ return $this->name;
103
+ }
104
+
105
+ /**
106
+ * @param string $name
107
+ */
108
+ public function setName($name) {
109
+ $this->name = $name;
110
+ }
111
+
112
+ /**
113
+ * @return string
114
+ */
115
+ public function getEmailAddress() {
116
+ return $this->emailAddress;
117
+ }
118
+
119
+ /**
120
+ * @param string $emailAddress
121
+ */
122
+ public function setEmailAddress($emailAddress) {
123
+ $this->emailAddress = $emailAddress;
124
+ }
125
+
126
+ /**
127
+ * @return string
128
+ */
129
+ public function getIpAddress() {
130
+ return $this->ipAddress;
131
+ }
132
+
133
+ /**
134
+ * @param string $ipAddress
135
+ */
136
+ public function setIpAddress($ipAddress) {
137
+ $this->ipAddress = $ipAddress;
138
+ }
139
+
140
+ /**
141
+ * @return string
142
+ */
143
+ public function getContent() {
144
+ return $this->content;
145
+ }
146
+
147
+ /**
148
+ * @param string $content
149
+ */
150
+ public function setContent($content) {
151
+ $this->content = $content;
152
+ }
153
+
154
+ /**
155
+ * @return string
156
+ */
157
+ public function getDate() {
158
+ return $this->date;
159
+ }
160
+
161
+ /**
162
+ * @param string $date
163
+ */
164
+ public function setDate($date) {
165
+ $this->date = $date;
166
+ }
167
+ }
Includes/Data/User.php ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WPGDPRC\Includes\Data;
4
+
5
+ /**
6
+ * Class User
7
+ * @package WPGDPRC\Includes\Data
8
+ */
9
+ class User {
10
+ /** @var null */
11
+ private static $instance = null;
12
+ /** @var int */
13
+ protected $id = 0;
14
+ /** @var string */
15
+ protected $username = '';
16
+ /** @var string */
17
+ protected $displayName = '';
18
+ /** @var string */
19
+ protected $emailAddress = '';
20
+ /** @var string */
21
+ protected $website = '';
22
+ /** @var array */
23
+ protected $metaData = array();
24
+ /** @var string */
25
+ protected $registeredDate = '';
26
+
27
+ /**
28
+ * User constructor.
29
+ * @param int $id
30
+ */
31
+ public function __construct($id = 0) {
32
+ if ((int)$id > 0) {
33
+ $this->setId($id);
34
+ $this->load();
35
+ $this->loadMetaData();
36
+ }
37
+ }
38
+
39
+ public function load() {
40
+ global $wpdb;
41
+ $query = "SELECT * FROM `" . $wpdb->users . "` WHERE `ID` = '%d'";
42
+ $row = $wpdb->get_row($wpdb->prepare($query, $this->getId()));
43
+ if ($row !== null) {
44
+ $this->loadByRow($row);
45
+ }
46
+ }
47
+
48
+ public function loadMetaData() {
49
+ $this->setMetaData($this->getMetaDataByUserId($this->getId()));
50
+ }
51
+
52
+ /**
53
+ * @param \stdClass $row
54
+ */
55
+ public function loadByRow(\stdClass $row) {
56
+ $this->setId($row->ID);
57
+ $this->setUsername($row->user_login);
58
+ $this->setDisplayName($row->display_name);
59
+ $this->setEmailAddress($row->user_email);
60
+ $this->setWebsite($row->user_url);
61
+ $this->setRegisteredDate($row->user_registered);
62
+ }
63
+
64
+ /**
65
+ * @param int $userId
66
+ * @return array
67
+ */
68
+ public function getMetaDataByUserId($userId = 0) {
69
+ global $wpdb;
70
+ $output = array();
71
+ $query = "SELECT * FROM `" . $wpdb->usermeta . "` WHERE `user_id` = '%d'";
72
+ $results = $wpdb->get_results($wpdb->prepare($query, $userId));
73
+ if ($results !== null) {
74
+ foreach ($results as $row) {
75
+ $output[] = $row;
76
+ }
77
+ }
78
+ return $output;
79
+ }
80
+
81
+ /**
82
+ * @return null|User
83
+ */
84
+ public static function getInstance() {
85
+ if (!isset(self::$instance)) {
86
+ self::$instance = new self();
87
+ }
88
+ return self::$instance;
89
+ }
90
+
91
+ /**
92
+ * @return int
93
+ */
94
+ public function getId() {
95
+ return $this->id;
96
+ }
97
+
98
+ /**
99
+ * @param int $id
100
+ */
101
+ public function setId($id) {
102
+ $this->id = $id;
103
+ }
104
+
105
+ /**
106
+ * @return string
107
+ */
108
+ public function getUsername() {
109
+ return $this->username;
110
+ }
111
+
112
+ /**
113
+ * @param string $username
114
+ */
115
+ public function setUsername($username) {
116
+ $this->username = $username;
117
+ }
118
+
119
+ /**
120
+ * @return string
121
+ */
122
+ public function getDisplayName() {
123
+ return $this->displayName;
124
+ }
125
+
126
+ /**
127
+ * @param string $displayName
128
+ */
129
+ public function setDisplayName($displayName) {
130
+ $this->displayName = $displayName;
131
+ }
132
+
133
+ /**
134
+ * @return string
135
+ */
136
+ public function getEmailAddress() {
137
+ return $this->emailAddress;
138
+ }
139
+
140
+ /**
141
+ * @param string $emailAddress
142
+ */
143
+ public function setEmailAddress($emailAddress) {
144
+ $this->emailAddress = $emailAddress;
145
+ }
146
+
147
+ /**
148
+ * @return string
149
+ */
150
+ public function getWebsite() {
151
+ return $this->website;
152
+ }
153
+
154
+ /**
155
+ * @param string $website
156
+ */
157
+ public function setWebsite($website) {
158
+ $this->website = $website;
159
+ }
160
+
161
+ /**
162
+ * @return array
163
+ */
164
+ public function getMetaData() {
165
+ return $this->metaData;
166
+ }
167
+
168
+ /**
169
+ * @param array $metaData
170
+ */
171
+ public function setMetaData($metaData) {
172
+ $this->metaData = $metaData;
173
+ }
174
+
175
+ /**
176
+ * @return string
177
+ */
178
+ public function getRegisteredDate() {
179
+ return $this->registeredDate;
180
+ }
181
+
182
+ /**
183
+ * @param string $registeredDate
184
+ */
185
+ public function setRegisteredDate($registeredDate) {
186
+ $this->registeredDate = $registeredDate;
187
+ }
188
+ }
Includes/Data/WooCommerceOrder.php ADDED
@@ -0,0 +1,392 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WPGDPRC\Includes\Data;
4
+
5
+ /**
6
+ * Class WooCommerceOrder
7
+ * @package WPGDPRC\Includes\Data
8
+ */
9
+ class WooCommerceOrder {
10
+ /** @var null */
11
+ private static $instance = null;
12
+ /** @var int */
13
+ protected $orderId = 0;
14
+ /** @var string */
15
+ protected $billingEmailAddress = '';
16
+ /** @var string */
17
+ protected $billingFirstName = '';
18
+ /** @var string */
19
+ protected $billingLastName = '';
20
+ /** @var string */
21
+ protected $billingCompany = '';
22
+ /** @var string */
23
+ protected $billingAddressOne = '';
24
+ /** @var string */
25
+ protected $billingAddressTwo = '';
26
+ /** @var string */
27
+ protected $billingCity = '';
28
+ /** @var string */
29
+ protected $billingState = '';
30
+ /** @var string */
31
+ protected $billingPostCode = '';
32
+ /** @var string */
33
+ protected $billingCountry = '';
34
+ /** @var string */
35
+ protected $billingPhone = '';
36
+ /** @var string */
37
+ protected $shippingFirstName = '';
38
+ /** @var string */
39
+ protected $shippingLastName = '';
40
+ /** @var string */
41
+ protected $shippingCompany = '';
42
+ /** @var string */
43
+ protected $shippingAddressOne = '';
44
+ /** @var string */
45
+ protected $shippingAddressTwo = '';
46
+ /** @var string */
47
+ protected $shippingCity = '';
48
+ /** @var string */
49
+ protected $shippingState = '';
50
+ /** @var string */
51
+ protected $shippingPostCode = '';
52
+ /** @var string */
53
+ protected $shippingCountry = '';
54
+
55
+ /**
56
+ * User constructor.
57
+ * @param int $orderId
58
+ */
59
+ public function __construct($orderId = 0) {
60
+ if ((int)$orderId > 0) {
61
+ $this->setOrderId($orderId);
62
+ $this->load();
63
+ }
64
+ }
65
+
66
+ public function load() {
67
+ $this->setBillingEmailAddress(get_post_meta($this->getOrderId(), '_billing_email', true));
68
+ $this->setBillingFirstName(get_post_meta($this->getOrderId(), '_billing_first_name', true));
69
+ $this->setBillingLastName(get_post_meta($this->getOrderId(), '_billing_last_name', true));
70
+ $this->setBillingCompany(get_post_meta($this->getOrderId(), '_billing_company', true));
71
+ $this->setBillingAddressOne(get_post_meta($this->getOrderId(), '_billing_address_1', true));
72
+ $this->setBillingAddressTwo(get_post_meta($this->getOrderId(), '_billing_address_2', true));
73
+ $this->setBillingCity(get_post_meta($this->getOrderId(), '_billing_city', true));
74
+ $this->setBillingState(get_post_meta($this->getOrderId(), '_billing_state', true));
75
+ $this->setBillingPostCode(get_post_meta($this->getOrderId(), '_billing_postcode', true));
76
+ $this->setBillingCountry(get_post_meta($this->getOrderId(), '_billing_country', true));
77
+ $this->setBillingPhone(get_post_meta($this->getOrderId(), '_billing_phone', true));
78
+ $this->setShippingFirstName(get_post_meta($this->getOrderId(), '_shipping_first_name', true));
79
+ $this->setShippingLastName(get_post_meta($this->getOrderId(), '_shipping_last_name', true));
80
+ $this->setShippingCompany(get_post_meta($this->getOrderId(), '_shipping_company', true));
81
+ $this->setShippingAddressOne(get_post_meta($this->getOrderId(), '_shipping_address_1', true));
82
+ $this->setShippingAddressTwo(get_post_meta($this->getOrderId(), '_shipping_address_2', true));
83
+ $this->setShippingCity(get_post_meta($this->getOrderId(), '_shipping_city', true));
84
+ $this->setShippingState(get_post_meta($this->getOrderId(), '_shipping_state', true));
85
+ $this->setShippingPostCode(get_post_meta($this->getOrderId(), '_shipping_postcode', true));
86
+ $this->setShippingCountry(get_post_meta($this->getOrderId(), '_shipping_country', true));
87
+ }
88
+
89
+ /**
90
+ * @return null|WooCommerceOrder
91
+ */
92
+ public static function getInstance() {
93
+ if (!isset(self::$instance)) {
94
+ self::$instance = new self();
95
+ }
96
+ return self::$instance;
97
+ }
98
+
99
+ /**
100
+ * @return int
101
+ */
102
+ public function getOrderId() {
103
+ return $this->orderId;
104
+ }
105
+
106
+ /**
107
+ * @param int $orderId
108
+ */
109
+ public function setOrderId($orderId) {
110
+ $this->orderId = $orderId;
111
+ }
112
+
113
+ /**
114
+ * @return string
115
+ */
116
+ public function getBillingEmailAddress() {
117
+ return $this->billingEmailAddress;
118
+ }
119
+
120
+ /**
121
+ * @param string $billingEmailAddress
122
+ */
123
+ public function setBillingEmailAddress($billingEmailAddress) {
124
+ $this->billingEmailAddress = $billingEmailAddress;
125
+ }
126
+
127
+ /**
128
+ * @return string
129
+ */
130
+ public function getBillingFirstName() {
131
+ return $this->billingFirstName;
132
+ }
133
+
134
+ /**
135
+ * @param string $billingFirstName
136
+ */
137
+ public function setBillingFirstName($billingFirstName) {
138
+ $this->billingFirstName = $billingFirstName;
139
+ }
140
+
141
+ /**
142
+ * @return string
143
+ */
144
+ public function getBillingLastName() {
145
+ return $this->billingLastName;
146
+ }
147
+
148
+ /**
149
+ * @param string $billingLastName
150
+ */
151
+ public function setBillingLastName($billingLastName) {
152
+ $this->billingLastName = $billingLastName;
153
+ }
154
+
155
+ /**
156
+ * @return string
157
+ */
158
+ public function getBillingCompany() {
159
+ return $this->billingCompany;
160
+ }
161
+
162
+ /**
163
+ * @param string $billingCompany
164
+ */
165
+ public function setBillingCompany($billingCompany) {
166
+ $this->billingCompany = $billingCompany;
167
+ }
168
+
169
+ /**
170
+ * @return string
171
+ */
172
+ public function getBillingAddressOne() {
173
+ return $this->billingAddressOne;
174
+ }
175
+
176
+ /**
177
+ * @param string $billingAddressOne
178
+ */
179
+ public function setBillingAddressOne($billingAddressOne) {
180
+ $this->billingAddressOne = $billingAddressOne;
181
+ }
182
+
183
+ /**
184
+ * @return string
185
+ */
186
+ public function getBillingAddressTwo() {
187
+ return $this->billingAddressTwo;
188
+ }
189
+
190
+ /**
191
+ * @param string $billingAddressTwo
192
+ */
193
+ public function setBillingAddressTwo($billingAddressTwo) {
194
+ $this->billingAddressTwo = $billingAddressTwo;
195
+ }
196
+
197
+ /**
198
+ * @return string
199
+ */
200
+ public function getBillingCity() {
201
+ return $this->billingCity;
202
+ }
203
+
204
+ /**
205
+ * @param string $billingCity
206
+ */
207
+ public function setBillingCity($billingCity) {
208
+ $this->billingCity = $billingCity;
209
+ }
210
+
211
+ /**
212
+ * @return string
213
+ */
214
+ public function getBillingState() {
215
+ return $this->billingState;
216
+ }
217
+
218
+ /**
219
+ * @param string $billingState
220
+ */
221
+ public function setBillingState($billingState) {
222
+ $this->billingState = $billingState;
223
+ }
224
+
225
+ /**
226
+ * @return string
227
+ */
228
+ public function getBillingPostCode() {
229
+ return $this->billingPostCode;
230
+ }
231
+
232
+ /**
233
+ * @param string $billingPostCode
234
+ */
235
+ public function setBillingPostCode($billingPostCode) {
236
+ $this->billingPostCode = $billingPostCode;
237
+ }
238
+
239
+ /**
240
+ * @return string
241
+ */
242
+ public function getBillingCountry() {
243
+ return $this->billingCountry;
244
+ }
245
+
246
+ /**
247
+ * @param string $billingCountry
248
+ */
249
+ public function setBillingCountry($billingCountry) {
250
+ $this->billingCountry = $billingCountry;
251
+ }
252
+
253
+ /**
254
+ * @return string
255
+ */
256
+ public function getBillingPhone() {
257
+ return $this->billingPhone;
258
+ }
259
+
260
+ /**
261
+ * @param string $billingPhone
262
+ */
263
+ public function setBillingPhone($billingPhone) {
264
+ $this->billingPhone = $billingPhone;
265
+ }
266
+
267
+ /**
268
+ * @return string
269
+ */
270
+ public function getShippingFirstName() {
271
+ return $this->shippingFirstName;
272
+ }
273
+
274
+ /**
275
+ * @param string $shippingFirstName
276
+ */
277
+ public function setShippingFirstName($shippingFirstName) {
278
+ $this->shippingFirstName = $shippingFirstName;
279
+ }
280
+
281
+ /**
282
+ * @return string
283
+ */
284
+ public function getShippingLastName() {
285
+ return $this->shippingLastName;
286
+ }
287
+
288
+ /**
289
+ * @param string $shippingLastName
290
+ */
291
+ public function setShippingLastName($shippingLastName) {
292
+ $this->shippingLastName = $shippingLastName;
293
+ }
294
+
295
+ /**
296
+ * @return string
297
+ */
298
+ public function getShippingCompany() {
299
+ return $this->shippingCompany;
300
+ }
301
+
302
+ /**
303
+ * @param string $shippingCompany
304
+ */
305
+ public function setShippingCompany($shippingCompany) {
306
+ $this->shippingCompany = $shippingCompany;
307
+ }
308
+
309
+ /**
310
+ * @return string
311
+ */
312
+ public function getShippingAddressOne() {
313
+ return $this->shippingAddressOne;
314
+ }
315
+
316
+ /**
317
+ * @param string $shippingAddressOne
318
+ */
319
+ public function setShippingAddressOne($shippingAddressOne) {
320
+ $this->shippingAddressOne = $shippingAddressOne;
321
+ }
322
+
323
+ /**
324
+ * @return string
325
+ */
326
+ public function getShippingAddressTwo() {
327
+ return $this->shippingAddressTwo;
328
+ }
329
+
330
+ /**
331
+ * @param string $shippingAddressTwo
332
+ */
333
+ public function setShippingAddressTwo($shippingAddressTwo) {
334
+ $this->shippingAddressTwo = $shippingAddressTwo;
335
+ }
336
+
337
+ /**
338
+ * @return string
339
+ */
340
+ public function getShippingCity() {
341
+ return $this->shippingCity;
342
+ }
343
+
344
+ /**
345
+ * @param string $shippingCity
346
+ */
347
+ public function setShippingCity($shippingCity) {
348
+ $this->shippingCity = $shippingCity;
349
+ }
350
+
351
+ /**
352
+ * @return string
353
+ */
354
+ public function getShippingState() {
355
+ return $this->shippingState;
356
+ }
357
+
358
+ /**
359
+ * @param string $shippingState
360
+ */
361
+ public function setShippingState($shippingState) {
362
+ $this->shippingState = $shippingState;
363
+ }
364
+
365
+ /**
366
+ * @return string
367
+ */
368
+ public function getShippingPostCode() {
369
+ return $this->shippingPostCode;
370
+ }
371
+
372
+ /**
373
+ * @param string $shippingPostCode
374
+ */
375
+ public function setShippingPostCode($shippingPostCode) {
376
+ $this->shippingPostCode = $shippingPostCode;
377
+ }
378
+
379
+ /**
380
+ * @return string
381
+ */
382
+ public function getShippingCountry() {
383
+ return $this->shippingCountry;
384
+ }
385
+
386
+ /**
387
+ * @param string $shippingCountry
388
+ */
389
+ public function setShippingCountry($shippingCountry) {
390
+ $this->shippingCountry = $shippingCountry;
391
+ }
392
+ }
Includes/DeleteRequest.php ADDED
@@ -0,0 +1,355 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WPGDPRC\Includes;
4
+
5
+ /**
6
+ * Class DeleteRequest
7
+ * @package WPGDPRC\Includes
8
+ */
9
+ class DeleteRequest {
10
+ /** @var null */
11
+ private static $instance = null;
12
+ /** @var int */
13
+ private $id = 0;
14
+ /** @var int */
15
+ private $siteId = 0;
16
+ /** @var int */
17
+ private $accessRequestId = 0;
18
+ /** @var string */
19
+ private $sessionId = '';
20
+ /** @var string */
21
+ private $ipAddress = '';
22
+ /** @var int */
23
+ private $dataId = 0;
24
+ /** @var string */
25
+ private $type = '';
26
+ /** @var int */
27
+ private $processed = 0;
28
+ /** @var string */
29
+ private $dateCreated = '';
30
+
31
+ /**
32
+ * DeleteRequest constructor.
33
+ * @param int $id
34
+ */
35
+ public function __construct($id = 0) {
36
+ if ((int)$id > 0) {
37
+ $this->setId($id);
38
+ $this->load();
39
+ }
40
+ }
41
+
42
+ /**
43
+ * @param string $type
44
+ * @param int $dataId
45
+ * @param int $accessRequestId
46
+ * @return bool|DeleteRequest
47
+ */
48
+ public function getByTypeAndDataIdAndAccessRequestId($type = '', $dataId = 0, $accessRequestId = 0) {
49
+ global $wpdb;
50
+ $query = "SELECT `ID` FROM `" . self::getDatabaseTableName() . "` WHERE `type` = '%s' AND `data_id` = '%d' AND `access_request_id` = '%d'";
51
+ $result = $wpdb->get_row($wpdb->prepare($query, $type, $dataId, $accessRequestId));
52
+ if ($result !== null) {
53
+ return new self($result->ID);
54
+ }
55
+ return false;
56
+ }
57
+
58
+ /**
59
+ * @param int $accessRequestId
60
+ * @return int
61
+ */
62
+ public function getAmountByAccessRequestId($accessRequestId = 0) {
63
+ global $wpdb;
64
+ $query = "SELECT COUNT(`ID`) FROM `" . self::getDatabaseTableName() . "` WHERE `access_request_id` = '%d' AND `processed` = '0'";
65
+ $result = $wpdb->get_var(
66
+ $wpdb->prepare(
67
+ $query,
68
+ intval($accessRequestId)
69
+ )
70
+ );
71
+ if ($result !== null) {
72
+ return absint($result);
73
+ }
74
+ return 0;
75
+ }
76
+
77
+ /**
78
+ * @param array $filters
79
+ * @return int
80
+ */
81
+ public function getTotal($filters = array()) {
82
+ global $wpdb;
83
+ $query = "SELECT COUNT(`ID`) FROM `" . self::getDatabaseTableName() . "` WHERE 1";
84
+ $query .= Helper::getQueryByFilters($filters);
85
+ $result = $wpdb->get_var($query);
86
+ if ($result !== null) {
87
+ return absint($result);
88
+ }
89
+ return 0;
90
+ }
91
+
92
+ /**
93
+ * @param array $filters
94
+ * @param int $limit
95
+ * @param int $offset
96
+ * @return DeleteRequest[]
97
+ */
98
+ public function getList($filters = array(), $limit = 0, $offset = 0) {
99
+ global $wpdb;
100
+ $output = array();
101
+ $query = "SELECT * FROM `" . self::getDatabaseTableName() . "` WHERE 1";
102
+ $query .= Helper::getQueryByFilters($filters);
103
+ $query .= " ORDER BY `date_created` DESC";
104
+ if (!empty($limit)) {
105
+ $query .= " LIMIT $offset, $limit";
106
+ }
107
+ $results = $wpdb->get_results($query);
108
+ if ($results !== null) {
109
+ foreach ($results as $row) {
110
+ $object = new self;
111
+ $object->loadByRow($row);
112
+ $output[] = $object;
113
+ }
114
+ }
115
+ return $output;
116
+ }
117
+
118
+ /**
119
+ * @param $row
120
+ */
121
+ private function loadByRow($row) {
122
+ $this->setId($row->ID);
123
+ $this->setSiteId($row->site_id);
124
+ $this->setAccessRequestId($row->access_request_id);
125
+ $this->setSessionId($row->session_id);
126
+ $this->setIpAddress($row->ip_address);
127
+ $this->setDataId($row->data_id);
128
+ $this->setType($row->type);
129
+ $this->setProcessed($row->processed);
130
+ $this->setDateCreated($row->date_created);
131
+ }
132
+
133
+ public function load() {
134
+ global $wpdb;
135
+ $query = "SELECT * FROM `" . self::getDatabaseTableName() . "` WHERE `ID` = '%d'";
136
+ $row = $wpdb->get_row($wpdb->prepare($query, $this->getId()));
137
+ if ($row !== null) {
138
+ $this->loadByRow($row);
139
+ }
140
+ }
141
+
142
+ /**
143
+ * @param int $id
144
+ * @return bool
145
+ */
146
+ public function exists($id = 0) {
147
+ global $wpdb;
148
+ $row = $wpdb->get_row(
149
+ $wpdb->prepare(
150
+ "SELECT * FROM `" . self::getDatabaseTableName() . "` WHERE `ID` = '%d'",
151
+ intval($id)
152
+ )
153
+ );
154
+ return ($row !== null);
155
+ }
156
+
157
+ /**
158
+ * @return bool|int
159
+ */
160
+ public function save() {
161
+ global $wpdb;
162
+ if ($this->exists($this->getId())) {
163
+ $wpdb->update(
164
+ self::getDatabaseTableName(),
165
+ array('processed' => $this->getProcessed()),
166
+ array('ID' => $this->getId()),
167
+ array('%d'),
168
+ array('%d')
169
+ );
170
+ return $this->getId();
171
+ } else {
172
+ $result = $wpdb->insert(
173
+ self::getDatabaseTableName(),
174
+ array(
175
+ 'site_id' => $this->getSiteId(),
176
+ 'access_request_id' => $this->getAccessRequestId(),
177
+ 'session_id' => $this->getSessionId(),
178
+ 'ip_address' => $this->getIpAddress(),
179
+ 'type' => $this->getType(),
180
+ 'data_id' => $this->getDataId(),
181
+ 'processed' => $this->getProcessed(),
182
+ 'date_created' => date_i18n('Y-m-d H:i:s'),
183
+ ),
184
+ array('%d', '%d', '%s', '%s', '%s', '%d', '%d', '%s')
185
+ );
186
+ if ($result !== false) {
187
+ $this->setId($wpdb->insert_id);
188
+ return $this->getId();
189
+ }
190
+ }
191
+ return false;
192
+ }
193
+
194
+ /**
195
+ * @return null|string
196
+ */
197
+ public function getManageUrl() {
198
+ switch ($this->getType()) {
199
+ case 'user' :
200
+ return get_edit_user_link($this->getDataId());
201
+ break;
202
+ case 'comment' :
203
+ return get_edit_comment_link($this->getDataId());
204
+ break;
205
+ case 'woocommerce_order' :
206
+ return get_edit_post_link($this->getDataId());
207
+ break;
208
+ }
209
+ return '';
210
+ }
211
+
212
+ /**
213
+ * @return null|DeleteRequest
214
+ */
215
+ public static function getInstance() {
216
+ if (!isset(self::$instance)) {
217
+ self::$instance = new self();
218
+ }
219
+ return self::$instance;
220
+ }
221
+
222
+ /**
223
+ * @return int
224
+ */
225
+ public function getId() {
226
+ return $this->id;
227
+ }
228
+
229
+ /**
230
+ * @param int $id
231
+ */
232
+ public function setId($id) {
233
+ $this->id = $id;
234
+ }
235
+
236
+ /**
237
+ * @return int
238
+ */
239
+ public function getSiteId() {
240
+ return $this->siteId;
241
+ }
242
+
243
+ /**
244
+ * @param int $siteId
245
+ */
246
+ public function setSiteId($siteId) {
247
+ $this->siteId = $siteId;
248
+ }
249
+
250
+ /**
251
+ * @return int
252
+ */
253
+ public function getAccessRequestId() {
254
+ return $this->accessRequestId;
255
+ }
256
+
257
+ /**
258
+ * @param int $accessRequestId
259
+ */
260
+ public function setAccessRequestId($accessRequestId) {
261
+ $this->accessRequestId = $accessRequestId;
262
+ }
263
+
264
+ /**
265
+ * @return string
266
+ */
267
+ public function getSessionId() {
268
+ return $this->sessionId;
269
+ }
270
+
271
+ /**
272
+ * @param string $sessionId
273
+ */
274
+ public function setSessionId($sessionId) {
275
+ $this->sessionId = $sessionId;
276
+ }
277
+
278
+ /**
279
+ * @return string
280
+ */
281
+ public function getIpAddress() {
282
+ return $this->ipAddress;
283
+ }
284
+
285
+ /**
286
+ * @param string $ipAddress
287
+ */
288
+ public function setIpAddress($ipAddress) {
289
+ $this->ipAddress = $ipAddress;
290
+ }
291
+
292
+ /**
293
+ * @return int
294
+ */
295
+ public function getDataId() {
296
+ return $this->dataId;
297
+ }
298
+
299
+ /**
300
+ * @param int $dataId
301
+ */
302
+ public function setDataId($dataId) {
303
+ $this->dataId = $dataId;
304
+ }
305
+
306
+ /**
307
+ * @return string
308
+ */
309
+ public function getType() {
310
+ return $this->type;
311
+ }
312
+
313
+ /**
314
+ * @param string $type
315
+ */
316
+ public function setType($type) {
317
+ $this->type = $type;
318
+ }
319
+
320
+ /**
321
+ * @return int
322
+ */
323
+ public function getProcessed() {
324
+ return $this->processed;
325
+ }
326
+
327
+ /**
328
+ * @param int $processed
329
+ */
330
+ public function setProcessed($processed) {
331
+ $this->processed = $processed;
332
+ }
333
+
334
+ /**
335
+ * @return string
336
+ */
337
+ public function getDateCreated() {
338
+ return $this->dateCreated;
339
+ }
340
+
341
+ /**
342
+ * @param string $dateCreated
343
+ */
344
+ public function setDateCreated($dateCreated) {
345
+ $this->dateCreated = $dateCreated;
346
+ }
347
+
348
+ /**
349
+ * @return string
350
+ */
351
+ public static function getDatabaseTableName() {
352
+ global $wpdb;
353
+ return $wpdb->base_prefix . 'wpgdprc_delete_requests';
354
+ }
355
+ }
Includes/Extensions/CF7.php CHANGED
@@ -2,8 +2,8 @@
2
 
3
  namespace WPGDPRC\Includes\Extensions;
4
 
5
- use WPGDPRC\Includes\Helpers;
6
- use WPGDPRC\Includes\Integrations;
7
 
8
  /**
9
  * Class CF7
@@ -18,7 +18,7 @@ class CF7 {
18
  public function processIntegration() {
19
  $this->removeFormTagFromForms();
20
  $this->removeAcceptedDateFromForms();
21
- if (Helpers::isEnabled(self::ID)) {
22
  $this->addFormTagToForms();
23
  $this->addAcceptedDateToForms();
24
  }
@@ -179,7 +179,7 @@ class CF7 {
179
  if (!empty($submission)) {
180
  $data = $submission->get_posted_data();
181
  if (isset($data['wpgdprc']) && $data['wpgdprc'] == 1) {
182
- $value = Helpers::localDateFormat(get_option('date_format') . ' ' . get_option('time_format'), time());
183
  } else {
184
  $value = __('Not accepted.', WP_GDPR_C_SLUG);
185
  }
@@ -259,11 +259,11 @@ class CF7 {
259
  $texts = $this->getFormTexts();
260
  if (!empty($texts[$formId])) {
261
  $result = esc_html($texts[$formId]);
262
- $result = ($insertPrivacyPolicyLink === true) ? Integrations::insertPrivacyPolicyLink($result) : $result;
263
  return apply_filters('wpgdprc_cf7_checkbox_text', $result, $formId);
264
  }
265
  }
266
- return Integrations::getCheckboxText();
267
  }
268
 
269
  /**
@@ -278,7 +278,7 @@ class CF7 {
278
  return apply_filters('wpgdprc_cf7_error_message', $result, $formId);
279
  }
280
  }
281
- return Integrations::getErrorMessage();
282
  }
283
 
284
  /**
2
 
3
  namespace WPGDPRC\Includes\Extensions;
4
 
5
+ use WPGDPRC\Includes\Helper;
6
+ use WPGDPRC\Includes\Integration;
7
 
8
  /**
9
  * Class CF7
18
  public function processIntegration() {
19
  $this->removeFormTagFromForms();
20
  $this->removeAcceptedDateFromForms();
21
+ if (Helper::isEnabled(self::ID)) {
22
  $this->addFormTagToForms();
23
  $this->addAcceptedDateToForms();
24
  }
179
  if (!empty($submission)) {
180
  $data = $submission->get_posted_data();
181
  if (isset($data['wpgdprc']) && $data['wpgdprc'] == 1) {
182
+ $value = Helper::localDateFormat(get_option('date_format') . ' ' . get_option('time_format'), time());
183
  } else {
184
  $value = __('Not accepted.', WP_GDPR_C_SLUG);
185
  }
259
  $texts = $this->getFormTexts();
260
  if (!empty($texts[$formId])) {
261
  $result = esc_html($texts[$formId]);
262
+ $result = ($insertPrivacyPolicyLink === true) ? Integration::insertPrivacyPolicyLink($result) : $result;
263
  return apply_filters('wpgdprc_cf7_checkbox_text', $result, $formId);
264
  }
265
  }
266
+ return Integration::getCheckboxText();
267
  }
268
 
269
  /**
278
  return apply_filters('wpgdprc_cf7_error_message', $result, $formId);
279
  }
280
  }
281
+ return Integration::getErrorMessage();
282
  }
283
 
284
  /**
Includes/Extensions/GForms.php CHANGED
@@ -2,8 +2,8 @@
2
 
3
  namespace WPGDPRC\Includes\Extensions;
4
 
5
- use WPGDPRC\Includes\Helpers;
6
- use WPGDPRC\Includes\Integrations;
7
 
8
  /**
9
  * Class GForms
@@ -20,7 +20,7 @@ class GForms {
20
  return;
21
  }
22
  foreach (self::getForms() as $form) {
23
- if (in_array($form['id'], self::getEnabledForms()) && Helpers::isEnabled(self::ID)) {
24
  self::addField($form);
25
  } else {
26
  self::removeField($form);
@@ -140,7 +140,7 @@ class GForms {
140
  public function addAcceptedDateToEntry($value = '', $lead = array(), \GF_Field $field) {
141
  if (isset($field['wpgdprc']) && $field['wpgdprc'] === true) {
142
  if (!empty($value)) {
143
- $date = Helpers::localDateFormat(get_option('date_format') . ' ' . get_option('time_format'), time());
144
  $value = sprintf(__('Accepted on %s.', WP_GDPR_C_SLUG), $date);
145
  } else {
146
  $value = __('Not accepted.', WP_GDPR_C_SLUG);
@@ -211,12 +211,12 @@ class GForms {
211
  if (!empty($formId)) {
212
  $texts = $this->getFormTexts();
213
  if (!empty($texts[$formId])) {
214
- $result = wp_kses($texts[$formId], Helpers::getAllowedHTMLTags(self::ID));
215
- $result = ($insertPrivacyPolicyLink === true) ? Integrations::insertPrivacyPolicyLink($result) : $result;
216
  return apply_filters('wpgdprc_gforms_checkbox_text', $result, $formId);
217
  }
218
  }
219
- return Integrations::getCheckboxText();
220
  }
221
 
222
  /**
@@ -227,11 +227,11 @@ class GForms {
227
  if (!empty($formId)) {
228
  $errors = $this->getFormErrorMessages();
229
  if (!empty($errors[$formId])) {
230
- $result = wp_kses($errors[$formId], Helpers::getAllowedHTMLTags(self::ID));
231
  return apply_filters('wpgdprc_gforms_error_message', $result, $formId);
232
  }
233
  }
234
- return Integrations::getErrorMessage();
235
  }
236
 
237
  /**
2
 
3
  namespace WPGDPRC\Includes\Extensions;
4
 
5
+ use WPGDPRC\Includes\Helper;
6
+ use WPGDPRC\Includes\Integration;
7
 
8
  /**
9
  * Class GForms
20
  return;
21
  }
22
  foreach (self::getForms() as $form) {
23
+ if (in_array($form['id'], self::getEnabledForms()) && Helper::isEnabled(self::ID)) {
24
  self::addField($form);
25
  } else {
26
  self::removeField($form);
140
  public function addAcceptedDateToEntry($value = '', $lead = array(), \GF_Field $field) {
141
  if (isset($field['wpgdprc']) && $field['wpgdprc'] === true) {
142
  if (!empty($value)) {
143
+ $date = Helper::localDateFormat(get_option('date_format') . ' ' . get_option('time_format'), time());
144
  $value = sprintf(__('Accepted on %s.', WP_GDPR_C_SLUG), $date);
145
  } else {
146
  $value = __('Not accepted.', WP_GDPR_C_SLUG);
211
  if (!empty($formId)) {
212
  $texts = $this->getFormTexts();
213
  if (!empty($texts[$formId])) {
214
+ $result = wp_kses($texts[$formId], Helper::getAllowedHTMLTags(self::ID));
215
+ $result = ($insertPrivacyPolicyLink === true) ? Integration::insertPrivacyPolicyLink($result) : $result;
216
  return apply_filters('wpgdprc_gforms_checkbox_text', $result, $formId);
217
  }
218
  }
219
+ return Integration::getCheckboxText();
220
  }
221
 
222
  /**
227
  if (!empty($formId)) {
228
  $errors = $this->getFormErrorMessages();
229
  if (!empty($errors[$formId])) {
230
+ $result = wp_kses($errors[$formId], Helper::getAllowedHTMLTags(self::ID));
231
  return apply_filters('wpgdprc_gforms_error_message', $result, $formId);
232
  }
233
  }
234
+ return Integration::getErrorMessage();
235
  }
236
 
237
  /**
Includes/Extensions/WC.php CHANGED
@@ -2,8 +2,8 @@
2
 
3
  namespace WPGDPRC\Includes\Extensions;
4
 
5
- use WPGDPRC\Includes\Helpers;
6
- use WPGDPRC\Includes\Integrations;
7
 
8
  /**
9
  * Class WC
@@ -22,7 +22,7 @@ class WC {
22
  $args = array(
23
  'type' => 'checkbox',
24
  'class' => array('wpgdprc-checkbox'),
25
- 'label' => Integrations::getCheckboxText(self::ID),
26
  'required' => true,
27
  );
28
  woocommerce_form_field('wpgdprc', apply_filters('wpgdprc_woocommerce_field_args', $args));
@@ -33,7 +33,7 @@ class WC {
33
  */
34
  public function checkPost() {
35
  if (!isset($_POST['wpgdprc'])) {
36
- wc_add_notice(Integrations::getErrorMessage(self::ID), 'error');
37
  }
38
  }
39
 
@@ -52,7 +52,7 @@ class WC {
52
  public function displayAcceptedDateInOrderData(\WC_Order $order) {
53
  $label = __('GDPR accepted on:', WP_GDPR_C_SLUG);
54
  $date = get_post_meta($order->get_id(), '_wpgdprc', true);
55
- $value = (!empty($date)) ? Helpers::localDateFormat(get_option('date_format') . ' ' . get_option('time_format'), $date) : __('Not accepted.', WP_GDPR_C_SLUG);
56
  echo apply_filters(
57
  'wpgdprc_woocommerce_accepted_date_in_order_data',
58
  sprintf('<p class="form-field form-field-wide wpgdprc-accepted-date"><strong>%s</strong><br />%s</p>', $label, $value),
2
 
3
  namespace WPGDPRC\Includes\Extensions;
4
 
5
+ use WPGDPRC\Includes\Helper;
6
+ use WPGDPRC\Includes\Integration;
7
 
8
  /**
9
  * Class WC
22
  $args = array(
23
  'type' => 'checkbox',
24
  'class' => array('wpgdprc-checkbox'),
25
+ 'label' => Integration::getCheckboxText(self::ID),
26
  'required' => true,
27
  );
28
  woocommerce_form_field('wpgdprc', apply_filters('wpgdprc_woocommerce_field_args', $args));
33
  */
34
  public function checkPost() {
35
  if (!isset($_POST['wpgdprc'])) {
36
+ wc_add_notice(Integration::getErrorMessage(self::ID), 'error');
37
  }
38
  }
39
 
52
  public function displayAcceptedDateInOrderData(\WC_Order $order) {
53
  $label = __('GDPR accepted on:', WP_GDPR_C_SLUG);
54
  $date = get_post_meta($order->get_id(), '_wpgdprc', true);
55
+ $value = (!empty($date)) ? Helper::localDateFormat(get_option('date_format') . ' ' . get_option('time_format'), $date) : __('Not accepted.', WP_GDPR_C_SLUG);
56
  echo apply_filters(
57
  'wpgdprc_woocommerce_accepted_date_in_order_data',
58
  sprintf('<p class="form-field form-field-wide wpgdprc-accepted-date"><strong>%s</strong><br />%s</p>', $label, $value),
Includes/Extensions/WP.php CHANGED
@@ -2,8 +2,8 @@
2
 
3
  namespace WPGDPRC\Includes\Extensions;
4
 
5
- use WPGDPRC\Includes\Helpers;
6
- use WPGDPRC\Includes\Integrations;
7
 
8
  /**
9
  * Class WP
@@ -19,7 +19,11 @@ class WP {
19
  * @return string
20
  */
21
  public function addField($submitField = '') {
22
- $field = apply_filters('wpgdprc_wordpress_field', '<p class="wpgdprc-checkbox"><label><input type="checkbox" name="wpgdprc" id="wpgdprc" value="1" />' . Integrations::getCheckboxText(self::ID) . ' <abbr class="required" title="required">*</abbr></label></p>', $submitField);
 
 
 
 
23
  return $field . $submitField;
24
  }
25
 
@@ -28,7 +32,7 @@ class WP {
28
  wp_die(
29
  '<p>' . sprintf(
30
  __('<strong>ERROR</strong>: %s', WP_GDPR_C_SLUG),
31
- Integrations::getErrorMessage(self::ID)
32
  ) . '</p>',
33
  __('Comment Submission Failure'),
34
  array('back_link' => true)
@@ -62,7 +66,7 @@ class WP {
62
  public function displayAcceptedDateInCommentOverview($column = '', $commentId = 0) {
63
  if ($column === 'wpgdprc') {
64
  $date = get_comment_meta($commentId, '_wpgdprc', true);
65
- $value = (!empty($date)) ? Helpers::localDateFormat(get_option('date_format') . ' ' . get_option('time_format'), $date) : __('Not accepted.', WP_GDPR_C_SLUG);
66
  echo apply_filters('wpgdprc_woocommerce_accepted_date_in_comment_overview', $value, $commentId);
67
  }
68
  return $column;
2
 
3
  namespace WPGDPRC\Includes\Extensions;
4
 
5
+ use WPGDPRC\Includes\Helper;
6
+ use WPGDPRC\Includes\Integration;
7
 
8
  /**
9
  * Class WP
19
  * @return string
20
  */
21
  public function addField($submitField = '') {
22
+ $field = apply_filters(
23
+ 'wpgdprc_wordpress_field',
24
+ '<p class="wpgdprc-checkbox"><label><input type="checkbox" name="wpgdprc" id="wpgdprc" value="1" />' . Integration::getCheckboxText(self::ID) . ' <abbr class="required" title="' . esc_attr__('required', WP_GDPR_C_SLUG) . '">*</abbr></label></p>',
25
+ $submitField
26
+ );
27
  return $field . $submitField;
28
  }
29
 
32
  wp_die(
33
  '<p>' . sprintf(
34
  __('<strong>ERROR</strong>: %s', WP_GDPR_C_SLUG),
35
+ Integration::getErrorMessage(self::ID)
36
  ) . '</p>',
37
  __('Comment Submission Failure'),
38
  array('back_link' => true)
66
  public function displayAcceptedDateInCommentOverview($column = '', $commentId = 0) {
67
  if ($column === 'wpgdprc') {
68
  $date = get_comment_meta($commentId, '_wpgdprc', true);
69
+ $value = (!empty($date)) ? Helper::localDateFormat(get_option('date_format') . ' ' . get_option('time_format'), $date) : __('Not accepted.', WP_GDPR_C_SLUG);
70
  echo apply_filters('wpgdprc_woocommerce_accepted_date_in_comment_overview', $value, $commentId);
71
  }
72
  return $column;
Includes/Filter.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WPGDPRC\Includes;
4
+
5
+ /**
6
+ * Class Filter
7
+ * @package WPGDPRC\Includes
8
+ */
9
+ class Filter {
10
+ /** @var null */
11
+ private static $instance = null;
12
+
13
+ public function processEnableAccessRequest($value) {
14
+ $enabled = Helper::isEnabled('enable_access_request', 'settings');
15
+ if (empty($value) && $enabled) {
16
+ $page = Helper::getAccessRequestPage();
17
+ if (!empty($page)) {
18
+ $value = $page->ID;
19
+ }
20
+ }
21
+ return $value;
22
+ }
23
+
24
+ /**
25
+ * @return null|Filter
26
+ */
27
+ public static function getInstance() {
28
+ if (!isset(self::$instance)) {
29
+ self::$instance = new self();
30
+ }
31
+ return self::$instance;
32
+ }
33
+ }
Includes/{Helpers.php → Helper.php} RENAMED
@@ -5,10 +5,10 @@ namespace WPGDPRC\Includes;
5
  use WPGDPRC\Includes\Extensions\CF7;
6
 
7
  /**
8
- * Class Helpers
9
  * @package WPGDPRC\Includes
10
  */
11
- class Helpers {
12
  /** @var null */
13
  private static $instance = null;
14
 
@@ -19,6 +19,16 @@ class Helpers {
19
  return get_plugin_data(WP_GDPR_C_ROOT_FILE);
20
  }
21
 
 
 
 
 
 
 
 
 
 
 
22
  /**
23
  * @param string $plugin
24
  * @return mixed
@@ -58,7 +68,7 @@ class Helpers {
58
  */
59
  public static function getAllowedHTMLTagsOutput($plugin = '') {
60
  $allowedTags = self::getAllowedHTMLTags($plugin);
61
- $output = '<div class="wpgdprc-allowed-tags">';
62
  if (!empty($allowedTags)) {
63
  $tags = '%privacy_policy%';
64
  foreach ($allowedTags as $tag => $attributes) {
@@ -158,12 +168,12 @@ class Helpers {
158
  }
159
 
160
  /**
161
- * @param string $plugin
162
  * @param string $type
163
  * @return bool
164
  */
165
- public static function isEnabled($plugin = '', $type = 'integrations') {
166
- return filter_var(get_option(WP_GDPR_C_PREFIX . '_' . $type . '_' . $plugin), FILTER_VALIDATE_BOOLEAN);
167
  }
168
 
169
  /**
@@ -190,7 +200,7 @@ class Helpers {
190
  $output = array();
191
  $activePlugins = self::getActivePlugins();
192
  // Loop through supported plugins
193
- foreach (Integrations::getSupportedPlugins() as $plugin) {
194
  if (in_array($plugin['file'], $activePlugins)) {
195
  if (is_admin()) {
196
  $plugin['supported'] = true;
@@ -206,7 +216,7 @@ class Helpers {
206
  }
207
 
208
  // Loop through supported WordPress functionality
209
- foreach (Integrations::getSupportedWordPressFunctionality() as $wp) {
210
  $wp['supported'] = true;
211
  $output[] = $wp;
212
  }
@@ -243,11 +253,10 @@ class Helpers {
243
  }
244
 
245
  /**
246
- * @param string $format
247
  * @param int $timestamp
248
- * @return string
249
  */
250
- public static function localDateFormat($format = '', $timestamp = 0) {
251
  $gmtOffset = get_option('gmt_offset', '');
252
  if ($gmtOffset !== '') {
253
  $negative = ($gmtOffset < 0);
@@ -266,12 +275,175 @@ class Helpers {
266
  $date = new \DateTime(null, new \DateTimeZone(get_option('timezone_string', 'UTC')));
267
  $date->setTimestamp($timestamp);
268
  }
269
- $date = new \DateTime($date->format('Y-m-d H:i:s'), new \DateTimeZone('UTC'));
 
 
 
 
 
 
 
 
 
270
  return date_i18n($format, $date->getTimestamp(), true);
271
  }
272
 
273
  /**
274
- * @return null|Helpers
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
275
  */
276
  public static function getInstance() {
277
  if (!isset(self::$instance)) {
5
  use WPGDPRC\Includes\Extensions\CF7;
6
 
7
  /**
8
+ * Class Helper
9
  * @package WPGDPRC\Includes
10
  */
11
+ class Helper {
12
  /** @var null */
13
  private static $instance = null;
14
 
19
  return get_plugin_data(WP_GDPR_C_ROOT_FILE);
20
  }
21
 
22
+ /**
23
+ * @return string
24
+ */
25
+ public static function getPluginAdminUrl() {
26
+ return admin_url(sprintf(
27
+ 'tools.php?page=%s',
28
+ str_replace('-', '_', WP_GDPR_C_SLUG)
29
+ ));
30
+ }
31
+
32
  /**
33
  * @param string $plugin
34
  * @return mixed
68
  */
69
  public static function getAllowedHTMLTagsOutput($plugin = '') {
70
  $allowedTags = self::getAllowedHTMLTags($plugin);
71
+ $output = '<div class="wpgdprc-information">';
72
  if (!empty($allowedTags)) {
73
  $tags = '%privacy_policy%';
74
  foreach ($allowedTags as $tag => $attributes) {
168
  }
169
 
170
  /**
171
+ * @param string $option
172
  * @param string $type
173
  * @return bool
174
  */
175
+ public static function isEnabled($option = '', $type = 'integrations') {
176
+ return filter_var(get_option(WP_GDPR_C_PREFIX . '_' . $type . '_' . $option), FILTER_VALIDATE_BOOLEAN);
177
  }
178
 
179
  /**
200
  $output = array();
201
  $activePlugins = self::getActivePlugins();
202
  // Loop through supported plugins
203
+ foreach (Integration::getSupportedPlugins() as $plugin) {
204
  if (in_array($plugin['file'], $activePlugins)) {
205
  if (is_admin()) {
206
  $plugin['supported'] = true;
216
  }
217
 
218
  // Loop through supported WordPress functionality
219
+ foreach (Integration::getSupportedWordPressFunctionality() as $wp) {
220
  $wp['supported'] = true;
221
  $output[] = $wp;
222
  }
253
  }
254
 
255
  /**
 
256
  * @param int $timestamp
257
+ * @return \DateTime
258
  */
259
+ public static function localDateTime($timestamp = 0) {
260
  $gmtOffset = get_option('gmt_offset', '');
261
  if ($gmtOffset !== '') {
262
  $negative = ($gmtOffset < 0);
275
  $date = new \DateTime(null, new \DateTimeZone(get_option('timezone_string', 'UTC')));
276
  $date->setTimestamp($timestamp);
277
  }
278
+ return new \DateTime($date->format('Y-m-d H:i:s'), new \DateTimeZone('UTC'));
279
+ }
280
+
281
+ /**
282
+ * @param string $format
283
+ * @param int $timestamp
284
+ * @return string
285
+ */
286
+ public static function localDateFormat($format = '', $timestamp = 0) {
287
+ $date = self::localDateTime($timestamp);
288
  return date_i18n($format, $date->getTimestamp(), true);
289
  }
290
 
291
  /**
292
+ * @param string $string
293
+ * @param int $length
294
+ * @param string $more
295
+ * @return string
296
+ */
297
+ public static function shortenStringByWords($string = '', $length = 20, $more = '...') {
298
+ $words = preg_split("/[\n\r\t ]+/", $string, $length + 1, PREG_SPLIT_NO_EMPTY);
299
+ if (count($words) > $length) {
300
+ array_pop($words);
301
+ $output = implode(' ', $words) . $more;
302
+ } else {
303
+ $output = implode(' ', $words);
304
+ }
305
+ return $output;
306
+ }
307
+
308
+ /**
309
+ * Ensures an ip address is both a valid IP and does not fall within
310
+ * a private network range.
311
+ *
312
+ * @param string $ipAddress
313
+ * @return bool
314
+ */
315
+ public static function validateIpAddress($ipAddress = '') {
316
+ if (strtolower($ipAddress) === 'unknown') {
317
+ return false;
318
+ }
319
+ // Generate ipv4 network address
320
+ $ipAddress = ip2long($ipAddress);
321
+ // If the ip is set and not equivalent to 255.255.255.255
322
+ if ($ipAddress !== false && $ipAddress !== -1) {
323
+ /**
324
+ * Make sure to get unsigned long representation of ip
325
+ * due to discrepancies between 32 and 64 bit OSes and
326
+ * signed numbers (ints default to signed in PHP)
327
+ */
328
+ $ipAddress = sprintf('%u', $ipAddress);
329
+ // Do private network range checking
330
+ if ($ipAddress >= 0 && $ipAddress <= 50331647) return false;
331
+ if ($ipAddress >= 167772160 && $ipAddress <= 184549375) return false;
332
+ if ($ipAddress >= 2130706432 && $ipAddress <= 2147483647) return false;
333
+ if ($ipAddress >= 2851995648 && $ipAddress <= 2852061183) return false;
334
+ if ($ipAddress >= 2886729728 && $ipAddress <= 2887778303) return false;
335
+ if ($ipAddress >= 3221225984 && $ipAddress <= 3221226239) return false;
336
+ if ($ipAddress >= 3232235520 && $ipAddress <= 3232301055) return false;
337
+ if ($ipAddress >= 4294967040) return false;
338
+ }
339
+ return true;
340
+ }
341
+
342
+ /**
343
+ * @return string
344
+ */
345
+ public static function getClientIpAddress() {
346
+ // Check for shared internet/ISP IP
347
+ if (!empty($_SERVER['HTTP_CLIENT_IP']) && self::validateIpAddress($_SERVER['HTTP_CLIENT_IP'])) {
348
+ return $_SERVER['HTTP_CLIENT_IP'];
349
+ }
350
+ // Check for IPs passing through proxies
351
+ if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
352
+ // Check if multiple ips exist in var
353
+ if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ',') !== false) {
354
+ $listOfIpAddresses = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
355
+ foreach ($listOfIpAddresses as $ipAddress) {
356
+ $ipAddress = trim($ipAddress);
357
+ if (self::validateIpAddress($ipAddress)) {
358
+ return $ipAddress;
359
+ }
360
+ }
361
+ } else {
362
+ if (self::validateIpAddress($_SERVER['HTTP_X_FORWARDED_FOR'])) {
363
+ return $_SERVER['HTTP_X_FORWARDED_FOR'];
364
+ }
365
+ }
366
+ }
367
+ if (!empty($_SERVER['HTTP_X_FORWARDED']) && self::validateIpAddress($_SERVER['HTTP_X_FORWARDED'])) {
368
+ return $_SERVER['HTTP_X_FORWARDED'];
369
+ }
370
+ if (!empty($_SERVER['HTTP_X_CLUSTER_CLIENT_IP']) && self::validateIpAddress($_SERVER['HTTP_X_CLUSTER_CLIENT_IP'])) {
371
+ return $_SERVER['HTTP_X_CLUSTER_CLIENT_IP'];
372
+ }
373
+ if (!empty($_SERVER['HTTP_FORWARDED_FOR']) && self::validateIpAddress($_SERVER['HTTP_FORWARDED_FOR'])) {
374
+ return $_SERVER['HTTP_FORWARDED_FOR'];
375
+ }
376
+ if (!empty($_SERVER['HTTP_FORWARDED']) && self::validateIpAddress($_SERVER['HTTP_FORWARDED'])) {
377
+ return $_SERVER['HTTP_FORWARDED'];
378
+ }
379
+ // Return unreliable ip since all else failed
380
+ return $_SERVER['REMOTE_ADDR'];
381
+ }
382
+
383
+ /**
384
+ * @param string $ipAddress
385
+ * @return bool
386
+ */
387
+ public static function checkIpAddress($ipAddress = '') {
388
+ return self::getClientIpAddress() === $ipAddress;
389
+ }
390
+
391
+ /**
392
+ * @return bool|\WP_Post
393
+ */
394
+ public static function getAccessRequestPage() {
395
+ $output = false;
396
+ $option = get_option(WP_GDPR_C_PREFIX . '_settings_access_request_page', 0);
397
+ if (!empty($option)) {
398
+ $output = get_post($option);
399
+ } else {
400
+ $page = get_pages(array(
401
+ 'post_type' => 'page',
402
+ 'post_status' => 'publish,private,draft',
403
+ 'number' => 1,
404
+ 'meta_key' => '_wpgdprc_access_request',
405
+ 'meta_value' => '1'
406
+ ));
407
+ if (!empty($page)) {
408
+ /** @var \WP_Post $output */
409
+ $output = $page[0];
410
+ }
411
+ }
412
+ return $output;
413
+ }
414
+
415
+ /**
416
+ * @param array $filters
417
+ * @param bool $grouped
418
+ * @return string
419
+ */
420
+ public static function getQueryByFilters($filters = array(), $grouped = false) {
421
+ $output = '';
422
+ if (!empty($filters)) {
423
+ $count = 0;
424
+ foreach ($filters as $column => $filter) {
425
+ if (isset($filter['columns'])) {
426
+ $output .= " AND ( ";
427
+ $output .= trim(self::getQueryByFilters($filter['columns'], true));
428
+ $output .= " )";
429
+ } else {
430
+ $value = (isset($filter['value'])) ? $filter['value'] : false;
431
+ if (!empty($value)) {
432
+ $or = (isset($filter['or']) && filter_var($filter['or'], FILTER_VALIDATE_BOOLEAN)) ? 'OR' : 'AND';
433
+ $or = ($grouped === true && $count === 0) ? '' : $or;
434
+ $compare = (isset($filter['compare'])) ? $filter['compare'] : '=';
435
+ $wildcard = (isset($filter['wildcard']) && filter_var($filter['wildcard'], FILTER_VALIDATE_BOOLEAN)) ? '%' : '';
436
+ $output .= " $or `$column` $compare '$wildcard$value$wildcard'";
437
+ }
438
+ }
439
+ $count++;
440
+ }
441
+ }
442
+ return $output;
443
+ }
444
+
445
+ /**
446
+ * @return null|Helper
447
  */
448
  public static function getInstance() {
449
  if (!isset(self::$instance)) {
Includes/{Integrations.php → Integration.php} RENAMED
@@ -8,19 +8,19 @@ use WPGDPRC\Includes\Extensions\WC;
8
  use WPGDPRC\Includes\Extensions\WP;
9
 
10
  /**
11
- * Class Integrations
12
  * @package WPGDPRC\Includes
13
  */
14
- class Integrations {
15
  /** @var null */
16
  private static $instance = null;
17
 
18
  /**
19
- * Integrations constructor.
20
  */
21
  public function __construct() {
22
  add_action('admin_init', array($this, 'registerSettings'));
23
- foreach (Helpers::getEnabledPlugins() as $plugin) {
24
  switch ($plugin['id']) {
25
  case WP::ID :
26
  add_filter('comment_form_submit_field', array(WP::getInstance(), 'addField'), 999);
@@ -61,23 +61,23 @@ class Integrations {
61
 
62
  public function registerSettings() {
63
  foreach (self::getSupportedIntegrations() as $plugin) {
64
- register_setting(WP_GDPR_C_SLUG, WP_GDPR_C_PREFIX . '_integrations_' . $plugin['id'], 'intval');
65
  switch ($plugin['id']) {
66
  case CF7::ID :
67
  add_action('update_option_' . WP_GDPR_C_PREFIX . '_integrations_' . $plugin['id'], array(CF7::getInstance(), 'processIntegration'));
68
- register_setting(WP_GDPR_C_SLUG, WP_GDPR_C_PREFIX . '_integrations_' . $plugin['id'] . '_forms');
69
- register_setting(WP_GDPR_C_SLUG, WP_GDPR_C_PREFIX . '_integrations_' . $plugin['id'] . '_form_text', array('sanitize_callback' => array(Helpers::getInstance(), 'sanitizeData')));
70
- register_setting(WP_GDPR_C_SLUG, WP_GDPR_C_PREFIX . '_integrations_' . $plugin['id'] . '_error_message', array('sanitize_callback' => array(Helpers::getInstance(), 'sanitizeData')));
71
  break;
72
  case GForms::ID :
73
  add_action('update_option_' . WP_GDPR_C_PREFIX . '_integrations_' . $plugin['id'], array(GForms::getInstance(), 'processIntegration'));
74
- register_setting(WP_GDPR_C_SLUG, WP_GDPR_C_PREFIX . '_integrations_' . $plugin['id'] . '_forms');
75
- register_setting(WP_GDPR_C_SLUG, WP_GDPR_C_PREFIX . '_integrations_' . $plugin['id'] . '_form_text');
76
- register_setting(WP_GDPR_C_SLUG, WP_GDPR_C_PREFIX . '_integrations_' . $plugin['id'] . '_error_message');
77
  break;
78
  default :
79
- register_setting(WP_GDPR_C_SLUG, WP_GDPR_C_PREFIX . '_integrations_' . $plugin['id'] . '_text');
80
- register_setting(WP_GDPR_C_SLUG, WP_GDPR_C_PREFIX . '_integrations_' . $plugin['id'] . '_error_message');
81
  break;
82
  }
83
  }
@@ -111,15 +111,19 @@ class Integrations {
111
  $output .= '<label for="' . $formSettingId . '"><strong>' . sprintf(__('Form: %s', WP_GDPR_C_SLUG), get_the_title($form)) . '</strong></label>';
112
  $output .= '<span class="wpgdprc-instructions">' . __('Activate for this form:', WP_GDPR_C_SLUG) . '</span>';
113
  $output .= '</div>';
114
- $output .= '<p class="wpgdprc-setting">';
115
  $output .= '<label for="' . $textSettingId . '">' . __('Checkbox text', WP_GDPR_C_SLUG) . '</label>';
 
116
  $output .= '<input type="text" name="' . $optionNameFormText . '[' . $form . ']' . '" class="regular-text" id="' . $textSettingId . '" placeholder="' . $text . '" value="' . $text . '" />';
117
- $output .= '</p>';
118
- $output .= '<p class="wpgdprc-setting">';
 
119
  $output .= '<label for="' . $errorSettingId . '">' . __('Error message', WP_GDPR_C_SLUG) . '</label>';
 
120
  $output .= '<input type="text" name="' . $optionNameErrorMessage . '[' . $form . ']' . '" class="regular-text" id="' . $errorSettingId . '" placeholder="' . $errorMessage . '" value="' . $errorMessage . '" />';
121
- $output .= '</p>';
122
- $output .= Helpers::getAllowedHTMLTagsOutput($plugin);
 
123
  $output .= '</li>';
124
  }
125
  $output .= '</ul>';
@@ -148,15 +152,19 @@ class Integrations {
148
  $output .= '<label for="' . $formSettingId . '"><strong>' . sprintf(__('Form: %s', WP_GDPR_C_SLUG), $form['title']) . '</strong></label>';
149
  $output .= '<span class="wpgdprc-instructions">' . __('Activate for this form:', WP_GDPR_C_SLUG) . '</span>';
150
  $output .= '</div>';
151
- $output .= '<p class="wpgdprc-setting">';
152
  $output .= '<label for="' . $textSettingId . '">' . __('Checkbox text', WP_GDPR_C_SLUG) . '</label>';
 
153
  $output .= '<input type="text" name="' . $optionNameFormText . '[' . $form['id'] . ']' . '" class="regular-text" id="' . $textSettingId . '" placeholder="' . $text . '" value="' . $text . '" />';
154
- $output .= '</p>';
155
- $output .= '<p class="wpgdprc-setting">';
 
156
  $output .= '<label for="' . $errorSettingId . '">' . __('Error message', WP_GDPR_C_SLUG) . '</label>';
 
157
  $output .= '<input type="text" name="' . $optionNameErrorMessage . '[' . $form['id'] . ']' . '" class="regular-text" id="' . $errorSettingId . '" placeholder="' . $errorMessage . '" value="' . $errorMessage . '" />';
158
- $output .= '</p>';
159
- $output .= Helpers::getAllowedHTMLTagsOutput($plugin);
 
160
  $output .= '</li>';
161
  }
162
  $output .= '</ul>';
@@ -171,15 +179,19 @@ class Integrations {
171
  $errorMessage = esc_html(self::getErrorMessage($plugin));
172
  $output .= '<ul class="wpgdprc-checklist-options">';
173
  $output .= '<li class="wpgdprc-clearfix">';
174
- $output .= '<p class="wpgdprc-setting">';
175
  $output .= '<label for="' . $optionNameText . '">' . __('Checkbox text', WP_GDPR_C_SLUG) . '</label>';
 
176
  $output .= '<input type="text" name="' . $optionNameText . '" class="regular-text" id="' . $optionNameText . '" placeholder="' . $text . '" value="' . $text . '" />';
177
- $output .= '</p>';
178
- $output .= '<p class="wpgdprc-setting">';
 
179
  $output .= '<label for="' . $optionNameErrorMessage . '">' . __('Error message', WP_GDPR_C_SLUG) . '</label>';
 
180
  $output .= '<input type="text" name="' . $optionNameErrorMessage . '" class="regular-text" id="' . $optionNameErrorMessage . '" placeholder="' . $errorMessage . '" value="' . $errorMessage . '" />';
181
- $output .= '</p>';
182
- $output .= Helpers::getAllowedHTMLTagsOutput($plugin);
 
183
  $output .= '</li>';
184
  $output .= '</ul>';
185
  break;
@@ -202,7 +214,7 @@ class Integrations {
202
  if (empty($output)) {
203
  $output = __('By using this form you agree with the storage and handling of your data by this website.', WP_GDPR_C_SLUG);
204
  }
205
- $output = wp_kses($output, Helpers::getAllowedHTMLTags($plugin));
206
  return apply_filters('wpgdprc_checkbox_text', $output);
207
  }
208
 
@@ -219,7 +231,7 @@ class Integrations {
219
  if (empty($output)) {
220
  $output = __('Please accept the privacy checkbox.', WP_GDPR_C_SLUG);
221
  }
222
- return apply_filters('wpgdprc_error_message', wp_kses($output, Helpers::getAllowedHTMLTags($plugin)));
223
  }
224
 
225
  /**
@@ -233,13 +245,41 @@ class Integrations {
233
  return apply_filters('wpgdprc_privacy_policy_text', $output);
234
  }
235
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
  /**
237
  * @param string $content
238
  * @return mixed|string
239
  */
240
  public static function insertPrivacyPolicyLink($content = '') {
241
  $page = get_option(WP_GDPR_C_PREFIX . '_settings_privacy_policy_page');
242
- $text = Integrations::getPrivacyPolicyText();
243
  if (!empty($page) && !empty($text)) {
244
  $link = apply_filters(
245
  'wpgdprc_privacy_policy_link',
@@ -318,7 +358,7 @@ class Integrations {
318
  }
319
 
320
  /**
321
- * @return null|Integrations
322
  */
323
  public static function getInstance() {
324
  if (!isset(self::$instance)) {
8
  use WPGDPRC\Includes\Extensions\WP;
9
 
10
  /**
11
+ * Class Integration
12
  * @package WPGDPRC\Includes
13
  */
14
+ class Integration {
15
  /** @var null */
16
  private static $instance = null;
17
 
18
  /**
19
+ * Integration constructor.
20
  */
21
  public function __construct() {
22
  add_action('admin_init', array($this, 'registerSettings'));
23
+ foreach (Helper::getEnabledPlugins() as $plugin) {
24
  switch ($plugin['id']) {
25
  case WP::ID :
26
  add_filter('comment_form_submit_field', array(WP::getInstance(), 'addField'), 999);
61
 
62
  public function registerSettings() {
63
  foreach (self::getSupportedIntegrations() as $plugin) {
64
+ register_setting(WP_GDPR_C_SLUG . '_integrations', WP_GDPR_C_PREFIX . '_integrations_' . $plugin['id'], 'intval');
65
  switch ($plugin['id']) {
66
  case CF7::ID :
67
  add_action('update_option_' . WP_GDPR_C_PREFIX . '_integrations_' . $plugin['id'], array(CF7::getInstance(), 'processIntegration'));
68
+ register_setting(WP_GDPR_C_SLUG . '_integrations', WP_GDPR_C_PREFIX . '_integrations_' . $plugin['id'] . '_forms');
69
+ register_setting(WP_GDPR_C_SLUG . '_integrations', WP_GDPR_C_PREFIX . '_integrations_' . $plugin['id'] . '_form_text', array('sanitize_callback' => array(Helper::getInstance(), 'sanitizeData')));
70
+ register_setting(WP_GDPR_C_SLUG . '_integrations', WP_GDPR_C_PREFIX . '_integrations_' . $plugin['id'] . '_error_message', array('sanitize_callback' => array(Helper::getInstance(), 'sanitizeData')));
71
  break;
72
  case GForms::ID :
73
  add_action('update_option_' . WP_GDPR_C_PREFIX . '_integrations_' . $plugin['id'], array(GForms::getInstance(), 'processIntegration'));
74
+ register_setting(WP_GDPR_C_SLUG . '_integrations', WP_GDPR_C_PREFIX . '_integrations_' . $plugin['id'] . '_forms');
75
+ register_setting(WP_GDPR_C_SLUG . '_integrations', WP_GDPR_C_PREFIX . '_integrations_' . $plugin['id'] . '_form_text');
76
+ register_setting(WP_GDPR_C_SLUG . '_integrations', WP_GDPR_C_PREFIX . '_integrations_' . $plugin['id'] . '_error_message');
77
  break;
78
  default :
79
+ register_setting(WP_GDPR_C_SLUG . '_integrations', WP_GDPR_C_PREFIX . '_integrations_' . $plugin['id'] . '_text');
80
+ register_setting(WP_GDPR_C_SLUG . '_integrations', WP_GDPR_C_PREFIX . '_integrations_' . $plugin['id'] . '_error_message');
81
  break;
82
  }
83
  }
111
  $output .= '<label for="' . $formSettingId . '"><strong>' . sprintf(__('Form: %s', WP_GDPR_C_SLUG), get_the_title($form)) . '</strong></label>';
112
  $output .= '<span class="wpgdprc-instructions">' . __('Activate for this form:', WP_GDPR_C_SLUG) . '</span>';
113
  $output .= '</div>';
114
+ $output .= '<div class="wpgdprc-setting">';
115
  $output .= '<label for="' . $textSettingId . '">' . __('Checkbox text', WP_GDPR_C_SLUG) . '</label>';
116
+ $output .= '<div class="wpgdprc-options">';
117
  $output .= '<input type="text" name="' . $optionNameFormText . '[' . $form . ']' . '" class="regular-text" id="' . $textSettingId . '" placeholder="' . $text . '" value="' . $text . '" />';
118
+ $output .= '</div>';
119
+ $output .= '</div>';
120
+ $output .= '<div class="wpgdprc-setting">';
121
  $output .= '<label for="' . $errorSettingId . '">' . __('Error message', WP_GDPR_C_SLUG) . '</label>';
122
+ $output .= '<div class="wpgdprc-options">';
123
  $output .= '<input type="text" name="' . $optionNameErrorMessage . '[' . $form . ']' . '" class="regular-text" id="' . $errorSettingId . '" placeholder="' . $errorMessage . '" value="' . $errorMessage . '" />';
124
+ $output .= '</div>';
125
+ $output .= '</div>';
126
+ $output .= Helper::getAllowedHTMLTagsOutput($plugin);
127
  $output .= '</li>';
128
  }
129
  $output .= '</ul>';
152
  $output .= '<label for="' . $formSettingId . '"><strong>' . sprintf(__('Form: %s', WP_GDPR_C_SLUG), $form['title']) . '</strong></label>';
153
  $output .= '<span class="wpgdprc-instructions">' . __('Activate for this form:', WP_GDPR_C_SLUG) . '</span>';
154
  $output .= '</div>';
155
+ $output .= '<div class="wpgdprc-setting">';
156
  $output .= '<label for="' . $textSettingId . '">' . __('Checkbox text', WP_GDPR_C_SLUG) . '</label>';
157
+ $output .= '<div class="wpgdprc-options">';
158
  $output .= '<input type="text" name="' . $optionNameFormText . '[' . $form['id'] . ']' . '" class="regular-text" id="' . $textSettingId . '" placeholder="' . $text . '" value="' . $text . '" />';
159
+ $output .= '</div>';
160
+ $output .= '</div>';
161
+ $output .= '<div class="wpgdprc-setting">';
162
  $output .= '<label for="' . $errorSettingId . '">' . __('Error message', WP_GDPR_C_SLUG) . '</label>';
163
+ $output .= '<div class="wpgdprc-options">';
164
  $output .= '<input type="text" name="' . $optionNameErrorMessage . '[' . $form['id'] . ']' . '" class="regular-text" id="' . $errorSettingId . '" placeholder="' . $errorMessage . '" value="' . $errorMessage . '" />';
165
+ $output .= '</div>';
166
+ $output .= '</div>';
167
+ $output .= Helper::getAllowedHTMLTagsOutput($plugin);
168
  $output .= '</li>';
169
  }
170
  $output .= '</ul>';
179
  $errorMessage = esc_html(self::getErrorMessage($plugin));
180
  $output .= '<ul class="wpgdprc-checklist-options">';
181
  $output .= '<li class="wpgdprc-clearfix">';
182
+ $output .= '<div class="wpgdprc-setting">';
183
  $output .= '<label for="' . $optionNameText . '">' . __('Checkbox text', WP_GDPR_C_SLUG) . '</label>';
184
+ $output .= '<div class="wpgdprc-options">';
185
  $output .= '<input type="text" name="' . $optionNameText . '" class="regular-text" id="' . $optionNameText . '" placeholder="' . $text . '" value="' . $text . '" />';
186
+ $output .= '</div>';
187
+ $output .= '</div>';
188
+ $output .= '<div class="wpgdprc-setting">';
189
  $output .= '<label for="' . $optionNameErrorMessage . '">' . __('Error message', WP_GDPR_C_SLUG) . '</label>';
190
+ $output .= '<div class="wpgdprc-options">';
191
  $output .= '<input type="text" name="' . $optionNameErrorMessage . '" class="regular-text" id="' . $optionNameErrorMessage . '" placeholder="' . $errorMessage . '" value="' . $errorMessage . '" />';
192
+ $output .= '</div>';
193
+ $output .= '</div>';
194
+ $output .= Helper::getAllowedHTMLTagsOutput($plugin);
195
  $output .= '</li>';
196
  $output .= '</ul>';
197
  break;
214
  if (empty($output)) {
215
  $output = __('By using this form you agree with the storage and handling of your data by this website.', WP_GDPR_C_SLUG);
216
  }
217
+ $output = wp_kses($output, Helper::getAllowedHTMLTags($plugin));
218
  return apply_filters('wpgdprc_checkbox_text', $output);
219
  }
220
 
231
  if (empty($output)) {
232
  $output = __('Please accept the privacy checkbox.', WP_GDPR_C_SLUG);
233
  }
234
+ return apply_filters('wpgdprc_error_message', wp_kses($output, Helper::getAllowedHTMLTags($plugin)));
235
  }
236
 
237
  /**
245
  return apply_filters('wpgdprc_privacy_policy_text', $output);
246
  }
247
 
248
+ /**
249
+ * @param bool $insertPrivacyPolicyLink
250
+ * @return mixed
251
+ */
252
+ public static function getAccessRequestFormCheckboxText($insertPrivacyPolicyLink = true) {
253
+ $output = get_option(WP_GDPR_C_PREFIX . '_settings_access_request_form_checkbox_text');
254
+ if (empty($output)) {
255
+ $output = __('By using this form you agree with the storage and handling of your data by this website.', WP_GDPR_C_SLUG);
256
+ }
257
+ $output = ($insertPrivacyPolicyLink === true) ? self::insertPrivacyPolicyLink($output) : $output;
258
+ return apply_filters('wpgdprc_access_request_form_checkbox_text', wp_kses($output, Helper::getAllowedHTMLTags()));
259
+ }
260
+
261
+ /**
262
+ * @return mixed
263
+ */
264
+ public static function getDeleteRequestFormExplanationText() {
265
+ $output = get_option(WP_GDPR_C_PREFIX . '_settings_delete_request_form_explanation_text');
266
+ if (empty($output)) {
267
+ $output = sprintf(
268
+ __('Below we show you all of the data stored by %s on %s Select the data you wish the site owner to anonymise so it cannot be linked to your email address any longer. It is the site\'s owner responsibility to act upon your request. When your data is anonymised you will receive an email confirmation.', WP_GDPR_C_SLUG),
269
+ get_option('blogname'),
270
+ get_option('siteurl')
271
+ );
272
+ }
273
+ return apply_filters('wpgdprc_delete_request_form_explanation_text', wp_kses($output, Helper::getAllowedHTMLTags()));
274
+ }
275
+
276
  /**
277
  * @param string $content
278
  * @return mixed|string
279
  */
280
  public static function insertPrivacyPolicyLink($content = '') {
281
  $page = get_option(WP_GDPR_C_PREFIX . '_settings_privacy_policy_page');
282
+ $text = Integration::getPrivacyPolicyText();
283
  if (!empty($page) && !empty($text)) {
284
  $link = apply_filters(
285
  'wpgdprc_privacy_policy_link',
358
  }
359
 
360
  /**
361
+ * @return null|Integration
362
  */
363
  public static function getInstance() {
364
  if (!isset(self::$instance)) {
Includes/Page.php ADDED
@@ -0,0 +1,531 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WPGDPRC\Includes;
4
+
5
+ /**
6
+ * Class Page
7
+ * @package WPGDPRC\Includes
8
+ */
9
+ class Page {
10
+ /** @var null */
11
+ private static $instance = null;
12
+
13
+ public function registerSettings() {
14
+ foreach (Helper::getCheckList() as $id => $check) {
15
+ register_setting(WP_GDPR_C_SLUG . '_general', WP_GDPR_C_PREFIX . '_general_' . $id, 'intval');
16
+ }
17
+ register_setting(WP_GDPR_C_SLUG . '_settings', WP_GDPR_C_PREFIX . '_settings_privacy_policy_page', 'intval');
18
+ register_setting(WP_GDPR_C_SLUG . '_settings', WP_GDPR_C_PREFIX . '_settings_privacy_policy_text', array('sanitize_callback' => array(Helper::getInstance(), 'sanitizeData')));
19
+ register_setting(WP_GDPR_C_SLUG . '_settings', WP_GDPR_C_PREFIX . '_settings_enable_access_request', 'intval');
20
+ if (Helper::isEnabled('enable_access_request', 'settings')) {
21
+ register_setting(WP_GDPR_C_SLUG . '_settings', WP_GDPR_C_PREFIX . '_settings_access_request_page', 'intval');
22
+ register_setting(WP_GDPR_C_SLUG . '_settings', WP_GDPR_C_PREFIX . '_settings_access_request_form_checkbox_text');
23
+ register_setting(WP_GDPR_C_SLUG . '_settings', WP_GDPR_C_PREFIX . '_settings_delete_request_form_explanation_text');
24
+ }
25
+ }
26
+
27
+ public function addAdminMenu() {
28
+ $pluginData = Helper::getPluginData();
29
+ add_submenu_page(
30
+ 'tools.php',
31
+ $pluginData['Name'],
32
+ $pluginData['Name'],
33
+ 'manage_options',
34
+ str_replace('-', '_', WP_GDPR_C_SLUG),
35
+ array($this, 'generatePage')
36
+ );
37
+ }
38
+
39
+ public function generatePage() {
40
+ $type = (isset($_REQUEST['type'])) ? esc_html($_REQUEST['type']) : false;
41
+ $pluginData = Helper::getPluginData();
42
+ $daysLeftToComply = Helper::getDaysLeftToComply();
43
+ $enableAccessRequest = Helper::isEnabled('enable_access_request', 'settings');
44
+ $adminUrl = Helper::getPluginAdminUrl();
45
+ ?>
46
+ <div class="wrap">
47
+ <div class="wpgdprc">
48
+ <h1 class="wpgdprc-title"><?php echo $pluginData['Name']; ?> <?php printf('v%s', $pluginData['Version']); ?></h1>
49
+
50
+ <?php settings_errors(); ?>
51
+
52
+ <div class="wpgdprc-navigation wpgdprc-clearfix">
53
+ <a class="<?php echo (empty($type)) ? 'wpgdprc-active' : ''; ?>" href="<?php echo $adminUrl; ?>"><?php _e('Integration', WP_GDPR_C_SLUG); ?></a>
54
+ <?php
55
+ if ($enableAccessRequest) :
56
+ $totalDeleteRequests = DeleteRequest::getInstance()->getTotal();
57
+ ?>
58
+ <a class="<?php echo checked('requests', $type, false) ? 'wpgdprc-active' : ''; ?>" href="<?php echo $adminUrl; ?>&type=requests">
59
+ <?php _e('Requests', WP_GDPR_C_SLUG); ?>
60
+ <?php
61
+ if ($totalDeleteRequests > 1) {
62
+ printf('<span class="wpgdprc-badge">%d</span>', $totalDeleteRequests);
63
+ } ?>
64
+ </a>
65
+ <?php
66
+ endif;
67
+ ?>
68
+ <a class="<?php echo checked('checklist', $type, false) ? 'wpgdprc-active' : ''; ?>" href="<?php echo $adminUrl; ?>&type=checklist"><?php _e('Checklist', WP_GDPR_C_SLUG); ?></a>
69
+ <a class="<?php echo checked('settings', $type, false) ? 'wpgdprc-active' : ''; ?>" href="<?php echo $adminUrl; ?>&type=settings"><?php _e('Settings', WP_GDPR_C_SLUG); ?></a>
70
+ </div>
71
+
72
+ <div class="wpgdprc-content wpgdprc-clearfix">
73
+ <?php
74
+ switch ($type) {
75
+ case 'requests' :
76
+ $id = (isset($_REQUEST['id']) && is_numeric($_REQUEST['id'])) ? intval($_REQUEST['id']) : 0;
77
+ if (!empty($id) && AccessRequest::getInstance()->exists($id)) {
78
+ self::renderManageRequestPage($id);
79
+ } else {
80
+ self::renderRequestsPage();
81
+ }
82
+ break;
83
+ case 'checklist' :
84
+ self::renderChecklistPage();
85
+ break;
86
+ case 'settings' :
87
+ self::renderSettingsPage();
88
+ break;
89
+ default :
90
+ self::renderIntegrationsPage();
91
+ break;
92
+ }
93
+ ?>
94
+ </div>
95
+
96
+ <div class="wpgdprc-description">
97
+ <p><?php _e('This plugin assists website and webshop owners to comply with European privacy regulations known as GDPR. By May 25th, 2018 your site or shop has to comply.', WP_GDPR_C_SLUG); ?></p>
98
+ <p><?php
99
+ printf(
100
+ __('%s currently supports %s. Please visit %s for frequently asked questions and our development roadmap.', WP_GDPR_C_SLUG),
101
+ $pluginData['Name'],
102
+ implode(', ', Integration::getSupportedIntegrationsLabels()),
103
+ sprintf('<a target="_blank" href="%s">%s</a>', '//www.wpgdprc.com/', 'www.wpgdprc.com')
104
+ );
105
+ ?></p>
106
+ </div>
107
+
108
+ <p class="wpgdprc-disclaimer"><?php _e('Disclaimer: The creators of this plugin do not have a legal background please contact a law firm for rock solid legal advice.', WP_GDPR_C_SLUG); ?></p>
109
+
110
+ <?php if ($daysLeftToComply > 0) : ?>
111
+ <div class="wpgdprc-countdown">
112
+ <div class="wpgdprc-countdown-inner">
113
+ <h2><?php echo date(get_option('date_format'), strtotime('25 May 2018')); ?></h2>
114
+ <p><?php printf(__('You have %s left to comply with GDPR.', WP_GDPR_C_SLUG), sprintf(_n('%s day', '%s days', $daysLeftToComply, WP_GDPR_C_SLUG), number_format_i18n($daysLeftToComply))); ?></p>
115
+ </div>
116
+ </div>
117
+ <?php endif; ?>
118
+
119
+ <div class="wpgdprc-background"><?php include(WP_GDPR_C_DIR_SVG . '/inline-waves.svg.php'); ?></div>
120
+ </div>
121
+ </div>
122
+ <?php
123
+ }
124
+
125
+ private static function renderIntegrationsPage() {
126
+ $pluginData = Helper::getPluginData();
127
+ $activatedPlugins = Helper::getActivatedPlugins();
128
+ ?>
129
+ <form method="post" action="<?php echo admin_url('options.php'); ?>" novalidate="novalidate">
130
+ <?php settings_fields(WP_GDPR_C_SLUG . '_integrations'); ?>
131
+ <?php if (!empty($activatedPlugins)) : ?>
132
+ <ul class="wpgdprc-list">
133
+ <?php
134
+ foreach ($activatedPlugins as $key => $plugin) :
135
+ $optionName = WP_GDPR_C_PREFIX . '_integrations_' . $plugin['id'];
136
+ $checked = Helper::isEnabled($plugin['id']);
137
+ $description = (!empty($plugin['description'])) ? apply_filters('the_content', $plugin['description']) : '';
138
+ $notices = Helper::getNotices($plugin['id']);
139
+ $options = Integration::getSupportedPluginOptions($plugin['id']);
140
+ ?>
141
+ <li class="wpgdprc-clearfix">
142
+ <?php if ($plugin['supported']) : ?>
143
+ <?php if (empty($notices)) : ?>
144
+ <div class="wpgdprc-checkbox">
145
+ <input type="checkbox" name="<?php echo $optionName; ?>" id="<?php echo $optionName; ?>" value="1" tabindex="1" data-type="save_setting" data-option="<?php echo $optionName; ?>" <?php checked(true, $checked); ?> />
146
+ <label for="<?php echo $optionName; ?>"><?php echo $plugin['name']; ?></label>
147
+ <span class="wpgdprc-instructions"><?php _e('Enable:', WP_GDPR_C_SLUG); ?></span>
148
+ <div class="wpgdprc-switch" aria-hidden="true">
149
+ <div class="wpgdprc-switch-label">
150
+ <div class="wpgdprc-switch-inner"></div>
151
+ <div class="wpgdprc-switch-switch"></div>
152
+ </div>
153
+ </div>
154
+ </div>
155
+
156
+ <div class="wpgdprc-checkbox-data" <?php if (!$checked) : ?>style="display: none;"<?php endif; ?>>
157
+ <?php if (!empty($description)) : ?>
158
+ <div class="wpgdprc-checklist-description">
159
+ <?php echo $description; ?>
160
+ </div>
161
+ <?php endif; ?>
162
+ <?php echo $options; ?>
163
+ </div>
164
+ <?php else : ?>
165
+ <div class="wpgdprc-message wpgdprc-message--notice">
166
+ <strong><?php echo $plugin['name']; ?></strong><br />
167
+ <?php echo $notices; ?>
168
+ </div>
169
+ <?php endif; ?>
170
+ <?php else : ?>
171
+ <div class="wpgdprc-message wpgdprc-message--error">
172
+ <strong><?php echo $plugin['name']; ?></strong><br />
173
+ <?php printf(__('This plugin is outdated. %s supports version %s and up.', WP_GDPR_C_SLUG), $pluginData['Name'], '<strong>' . $plugin['supported_version'] . '</strong>'); ?>
174
+ </div>
175
+ <?php endif; ?>
176
+ </li>
177
+ <?php
178
+ endforeach;
179
+ ?>
180
+ </ul>
181
+ <?php else : ?>
182
+ <p><strong><?php _e('Couldn\'t find any supported plugins installed.', WP_GDPR_C_SLUG); ?></strong></p>
183
+ <p><?php _e('The following plugins are supported as of now:', WP_GDPR_C_SLUG); ?></p>
184
+ <ul class="ul-square">
185
+ <?php foreach (Integration::getSupportedPlugins() as $plugin) : ?>
186
+ <li><?php echo $plugin['name']; ?></li>
187
+ <?php endforeach; ?>
188
+ </ul>
189
+ <p><?php _e('More plugins will be added in the future.', WP_GDPR_C_SLUG); ?></p>
190
+ <?php endif; ?>
191
+ <?php submit_button(); ?>
192
+ </form>
193
+ <?php
194
+ }
195
+
196
+ /**
197
+ * Page: Checklist
198
+ */
199
+ private static function renderChecklistPage() {
200
+ ?>
201
+ <p><?php _e('Below we ask you what private data you currently collect and provide you with tips to comply.', WP_GDPR_C_SLUG); ?></p>
202
+ <ul class="wpgdprc-list">
203
+ <?php
204
+ foreach (Helper::getCheckList() as $id => $check) :
205
+ $optionName = WP_GDPR_C_PREFIX . '_general_' . $id;
206
+ $checked = Helper::isEnabled($id, 'general');
207
+ $description = (!empty($check['description'])) ? esc_html($check['description']) : '';
208
+ ?>
209
+ <li class="wpgdprc-clearfix">
210
+ <div class="wpgdprc-checkbox">
211
+ <input type="checkbox" name="<?php echo $optionName; ?>" id="<?php echo $id; ?>" value="1" tabindex="1" data-type="save_setting" data-option="<?php echo $optionName; ?>" <?php checked(true, $checked); ?> />
212
+ <label for="<?php echo $id; ?>"><?php echo $check['label']; ?></label>
213
+ <div class="wpgdprc-switch wpgdprc-switch--reverse" aria-hidden="true">
214
+ <div class="wpgdprc-switch-label">
215
+ <div class="wpgdprc-switch-inner"></div>
216
+ <div class="wpgdprc-switch-switch"></div>
217
+ </div>
218
+ </div>
219
+ </div>
220
+
221
+ <?php if (!empty($description)) : ?>
222
+ <div class="wpgdprc-checkbox-data" <?php if (!$checked) : ?>style="display: none;"<?php endif; ?>>
223
+ <div class="wpgdprc-checklist-description">
224
+ <?php echo $description; ?>
225
+ </div>
226
+ </div>
227
+ <?php endif; ?>
228
+ </li>
229
+ <?php
230
+ endforeach;
231
+ ?>
232
+ </ul>
233
+ <?php
234
+ }
235
+
236
+ /**
237
+ * Page: Settings
238
+ */
239
+ private static function renderSettingsPage() {
240
+ $optionNamePrivacyPolicyPage = WP_GDPR_C_PREFIX . '_settings_privacy_policy_page';
241
+ $optionNamePrivacyPolicyText = WP_GDPR_C_PREFIX . '_settings_privacy_policy_text';
242
+ $optionNameEnableAccessRequest = WP_GDPR_C_PREFIX . '_settings_enable_access_request';
243
+ $optionNameAccessRequestPage = WP_GDPR_C_PREFIX . '_settings_access_request_page';
244
+ $optionNameAccessRequestFormCheckboxText = WP_GDPR_C_PREFIX . '_settings_access_request_form_checkbox_text';
245
+ $optionNameDeleteRequestFormExplanationText = WP_GDPR_C_PREFIX . '_settings_delete_request_form_explanation_text';
246
+ $privacyPolicyPage = get_option($optionNamePrivacyPolicyPage);
247
+ $privacyPolicyText = esc_html(Integration::getPrivacyPolicyText());
248
+ $enableAccessRequest = Helper::isEnabled('enable_access_request', 'settings');
249
+ $accessRequestPage = get_option($optionNameAccessRequestPage);
250
+ $accessRequestFormCheckboxText = Integration::getAccessRequestFormCheckboxText(false);
251
+ $deleteRequestFormExplanationText = Integration::getDeleteRequestFormExplanationText();
252
+ ?>
253
+ <p><strong><?php _e('Privacy Policy', WP_GDPR_C_SLUG); ?></strong></p>
254
+ <form method="post" action="<?php echo admin_url('options.php'); ?>" novalidate="novalidate">
255
+ <?php settings_fields(WP_GDPR_C_SLUG . '_settings'); ?>
256
+ <div class="wpgdprc-setting">
257
+ <label for="<?php echo $optionNamePrivacyPolicyPage; ?>"><?php _e('Privacy Policy', WP_GDPR_C_SLUG); ?></label>
258
+ <div class="wpgdprc-options">
259
+ <?php
260
+ wp_dropdown_pages(array(
261
+ 'post_status' => 'publish,private,draft',
262
+ 'show_option_none' => __('Select an option', WP_GDPR_C_SLUG),
263
+ 'name' => $optionNamePrivacyPolicyPage,
264
+ 'selected' => $privacyPolicyPage
265
+ ));
266
+ ?>
267
+ </div>
268
+ </div>
269
+ <div class="wpgdprc-setting">
270
+ <label for="<?php echo $optionNamePrivacyPolicyText; ?>"><?php _e('Link text', WP_GDPR_C_SLUG); ?></label>
271
+ <div class="wpgdprc-options">
272
+ <input type="text" name="<?php echo $optionNamePrivacyPolicyText; ?>" class="regular-text" id="<?php echo $optionNamePrivacyPolicyText; ?>" placeholder="<?php echo $privacyPolicyText; ?>" value="<?php echo $privacyPolicyText; ?>" />
273
+ </div>
274
+ </div>
275
+ <p><strong><?php _e('Request User Data', WP_GDPR_C_SLUG); ?></strong></p>
276
+ <div class="wpgdprc-information">
277
+ <p><?php _e('Allow your site\'s visitors to request their data stored in the WordPress database (comments, WooCommerce orders etc.). Data found is send to their email address and allows them to put in an additional request to have the data anonymised.', WP_GDPR_C_SLUG); ?></p>
278
+ </div>
279
+ <div class="wpgdprc-setting">
280
+ <label for="<?php echo $optionNameEnableAccessRequest; ?>"><?php _e('Activate', WP_GDPR_C_SLUG); ?></label>
281
+ <div class="wpgdprc-options">
282
+ <label><input type="checkbox" name="<?php echo $optionNameEnableAccessRequest; ?>" id="<?php echo $optionNameEnableAccessRequest; ?>" value="1" tabindex="1" data-type="save_setting" data-option="<?php echo $optionNameEnableAccessRequest; ?>" <?php checked(true, $enableAccessRequest); ?> /> <?php _e('Activate page', WP_GDPR_C_SLUG); ?></label>
283
+ <div class="wpgdprc-information">
284
+ <?php
285
+ printf(
286
+ '<strong>%s:</strong> %s',
287
+ strtoupper(__('Note', WP_GDPR_C_SLUG)),
288
+ __('Enabling this will create one private page containing the necessary shortcode. You can determine when and how to publish this page yourself.', WP_GDPR_C_SLUG)
289
+ );
290
+ ?>
291
+ </div>
292
+ </div>
293
+ </div>
294
+ <?php if ($enableAccessRequest) : ?>
295
+ <div class="wpgdprc-setting">
296
+ <label for="<?php echo $optionNameAccessRequestPage; ?>"><?php _e('Page', WP_GDPR_C_SLUG); ?></label>
297
+ <div class="wpgdprc-options">
298
+ <?php
299
+ wp_dropdown_pages(array(
300
+ 'post_status' => 'publish,private,draft',
301
+ 'show_option_none' => __('Select an option', WP_GDPR_C_SLUG),
302
+ 'name' => $optionNameAccessRequestPage,
303
+ 'selected' => $accessRequestPage
304
+ ));
305
+ ?>
306
+ <?php if (!empty($accessRequestPage)) : ?>
307
+ <div class="wpgdprc-information">
308
+ <?php printf('<a href="%s">%s</a>', get_edit_post_link($accessRequestPage), __('Click here to edit this page', WP_GDPR_C_SLUG)); ?>
309
+ </div>
310
+ <?php endif; ?>
311
+ </div>
312
+ </div>
313
+ <div class="wpgdprc-setting">
314
+ <label for="<?php echo $optionNameAccessRequestFormCheckboxText; ?>"><?php _e('Checkbox text', WP_GDPR_C_SLUG); ?></label>
315
+ <div class="wpgdprc-options">
316
+ <input type="text" name="<?php echo $optionNameAccessRequestFormCheckboxText; ?>" class="regular-text" id="<?php echo $optionNameAccessRequestFormCheckboxText; ?>" placeholder="<?php echo $accessRequestFormCheckboxText; ?>" value="<?php echo $accessRequestFormCheckboxText; ?>" />
317
+ </div>
318
+ </div>
319
+ <div class="wpgdprc-setting">
320
+ <label for="<?php echo $optionNameDeleteRequestFormExplanationText; ?>"><?php _e('Delete request explanation', WP_GDPR_C_SLUG); ?></label>
321
+ <div class="wpgdprc-options">
322
+ <textarea name="<?php echo $optionNameDeleteRequestFormExplanationText; ?>" rows="5" id="<?php echo $optionNameAccessRequestFormCheckboxText; ?>" placeholder="<?php echo $deleteRequestFormExplanationText; ?>"><?php echo $deleteRequestFormExplanationText; ?></textarea>
323
+ <?php echo Helper::getAllowedHTMLTagsOutput(); ?>
324
+ </div>
325
+ </div>
326
+ <?php endif; ?>
327
+ <?php submit_button(); ?>
328
+ </form>
329
+ <?php
330
+ }
331
+
332
+ /**
333
+ * @param int $requestId
334
+ */
335
+ private static function renderManageRequestPage($requestId = 0) {
336
+ $accessRequest = new AccessRequest($requestId);
337
+ $filters = array(
338
+ 'access_request_id' => array(
339
+ 'value' => $accessRequest->getId(),
340
+ ),
341
+ );
342
+ $paged = (isset($_REQUEST['paged'])) ? absint($_REQUEST['paged']) : 1;
343
+ $limit = 20;
344
+ $offset = ($paged - 1) * $limit;
345
+ $total = DeleteRequest::getInstance()->getTotal($filters);
346
+ $numberOfPages = ceil($total / $limit);
347
+ $requests = DeleteRequest::getInstance()->getList($filters, $limit, $offset);
348
+ if (!empty($requests)) :
349
+ ?>
350
+ <div class="wpgdprc-message wpgdprc-message--notice">
351
+ <p><?php _e('Anonymise a request by ticking the checkbox and clicking on the green anonymise button below.', WP_GDPR_C_SLUG); ?></p>
352
+ <p>
353
+ <?php printf('<strong>%s:</strong> %s', __('WordPress Users', WP_GDPR_C_SLUG), 'Anonymises first and last name, display name, nickname and email address.', WP_GDPR_C_SLUG); ?><br />
354
+ <?php printf('<strong>%s:</strong> %s', __('WordPress Comments', WP_GDPR_C_SLUG), 'Anonymises author name, email address and IP address.', WP_GDPR_C_SLUG); ?><br />
355
+ <?php printf('<strong>%s:</strong> %s', __('WooCommerce', WP_GDPR_C_SLUG), 'Anonymises billing and shipping details per order.', WP_GDPR_C_SLUG); ?>
356
+ </p>
357
+ </div>
358
+
359
+ <form class="wpgdprc-form wpgdprc-form--process-delete-requests" method="POST" novalidate="novalidate">
360
+ <div class="wpgdprc-feedback" style="display: none;"></div>
361
+ <table class="wpgdprc-table">
362
+ <thead>
363
+ <tr>
364
+ <th scope="col" width="10%"><?php _e('Request', WP_GDPR_C_SLUG); ?></th>
365
+ <th scope="col" width="22%"><?php _e('Type', WP_GDPR_C_SLUG); ?></th>
366
+ <th scope="col" width="18%"><?php _e('IP Address', WP_GDPR_C_SLUG); ?></th>
367
+ <th scope="col" width="22%"><?php _e('Date', WP_GDPR_C_SLUG); ?></th>
368
+ <th scope="col" width="12%"><?php _e('Processed', WP_GDPR_C_SLUG); ?></th>
369
+ <th scope="col" width="10%"><?php _e('Action', WP_GDPR_C_SLUG); ?></th>
370
+ <th scope="col" width="6%"><input type="checkbox" class="wpgdprc-select-all" /></th>
371
+ </tr>
372
+ </thead>
373
+ <tbody>
374
+ <?php
375
+ /** @var DeleteRequest $request */
376
+ foreach ($requests as $request) :
377
+ ?>
378
+ <tr data-id="<?php echo $request->getId(); ?>">
379
+ <td><?php printf('#%d', $request->getId()); ?></td>
380
+ <td><?php echo $request->getType(); ?></td>
381
+ <td><?php echo $request->getIpAddress(); ?></td>
382
+ <td><?php echo $request->getDateCreated(); ?></td>
383
+ <td><span class="dashicons dashicons-<?php echo ($request->getProcessed()) ? 'yes' : 'no'; ?>"></span></td>
384
+ <td><?php printf('<a target="_blank" href="%s">%s</a>', $request->getManageUrl(), __('View', WP_GDPR_C_SLUG)); ?></td>
385
+ <td>
386
+ <?php if (!$request->getProcessed()) : ?>
387
+ <input type="checkbox" class="wpgdprc-checkbox" value="<?php echo $request->getId(); ?>" />
388
+ <?php else : ?>
389
+ &nbsp;
390
+ <?php endif; ?>
391
+ </td>
392
+ </tr>
393
+ <?php
394
+ endforeach;
395
+ ?>
396
+ </tbody>
397
+ </table>
398
+ <?php submit_button(__('Anonymise selected request(s)', WP_GDPR_C_SLUG), 'primary wpgdprc-remove'); ?>
399
+ </form>
400
+
401
+ <div class="wpgdprc-pagination">
402
+ <?php
403
+ echo paginate_links(array(
404
+ 'base' => str_replace(
405
+ 999999999,
406
+ '%#%',
407
+ add_query_arg(
408
+ array('paged' => 999999999),
409
+ Helper::getPluginAdminUrl()
410
+ )
411
+ ),
412
+ 'format' => '?paged=%#%',
413
+ 'current' => max(1, $paged),
414
+ 'total' => $numberOfPages,
415
+ 'prev_text' => '&lsaquo;',
416
+ 'next_text' => '&rsaquo;',
417
+ 'before_page_number' => '<span>',
418
+ 'after_page_number' => '</span>'
419
+ ));
420
+ printf('<span class="wpgdprc-pagination__results">%s</span>', sprintf(__('%d of %d results found', WP_GDPR_C_SLUG), count($requests), $total));
421
+ ?>
422
+ </div>
423
+ <?php
424
+ else :
425
+ ?>
426
+ <p><strong><?php _e('No delete requests found.', WP_GDPR_C_SLUG); ?></strong></p>
427
+ <?php
428
+ endif;
429
+ ?>
430
+ <?php
431
+ }
432
+
433
+ /**
434
+ * Page: Requests
435
+ */
436
+ private static function renderRequestsPage() {
437
+ $paged = (isset($_REQUEST['paged'])) ? absint($_REQUEST['paged']) : 1;
438
+ $limit = 20;
439
+ $offset = ($paged - 1) * $limit;
440
+ $total = AccessRequest::getInstance()->getTotal();
441
+ $numberOfPages = ceil($total / $limit);
442
+ $requests = AccessRequest::getInstance()->getList(array(), $limit, $offset);
443
+ if (!empty($requests)) :
444
+ ?>
445
+ <table class="wpgdprc-table">
446
+ <thead>
447
+ <tr>
448
+ <th scope="col" width="10%"><?php _e('ID', WP_GDPR_C_SLUG); ?></th>
449
+ <th scope="col" width="20%"><?php _e('Requests to Process', WP_GDPR_C_SLUG); ?></th>
450
+ <th scope="col" width="22%"><?php _e('Email Address', WP_GDPR_C_SLUG); ?></th>
451
+ <th scope="col" width="18%"><?php _e('IP Address', WP_GDPR_C_SLUG); ?></th>
452
+ <th scope="col" width="22%"><?php _e('Date', WP_GDPR_C_SLUG); ?></th>
453
+ <th scope="col" width="8%"><?php _e('Expired', WP_GDPR_C_SLUG); ?></th>
454
+ </tr>
455
+ </thead>
456
+ <tbody>
457
+ <?php
458
+ /** @var AccessRequest $request */
459
+ foreach ($requests as $request) :
460
+ $amountOfDeleteRequests = DeleteRequest::getInstance()->getAmountByAccessRequestId($request->getId());
461
+ ?>
462
+ <tr>
463
+ <td><?php printf('#%d', $request->getId()); ?></td>
464
+ <td>
465
+ <?php printf('%d', $amountOfDeleteRequests); ?>
466
+ <?php
467
+ if ($amountOfDeleteRequests > 0) {
468
+ printf(
469
+ '<a href="%s">%s</a>',
470
+ add_query_arg(
471
+ array(
472
+ 'type' => 'requests',
473
+ 'id' => $request->getId()
474
+ ),
475
+ Helper::getPluginAdminUrl()
476
+ ),
477
+ __('Manage', WP_GDPR_C_SLUG)
478
+ );
479
+ }
480
+ ?>
481
+ </td>
482
+ <td><?php echo $request->getEmailAddress(); ?></td>
483
+ <td><?php echo $request->getIpAddress(); ?></td>
484
+ <td><?php echo $request->getDateCreated(); ?></td>
485
+ <td><span class="dashicons dashicons-<?php echo ($request->getExpired()) ? 'yes' : 'no'; ?>"></span></td>
486
+ </tr>
487
+ <?php
488
+ endforeach;
489
+ ?>
490
+ </tbody>
491
+ </table>
492
+ <div class="wpgdprc-pagination">
493
+ <?php
494
+ echo paginate_links(array(
495
+ 'base' => str_replace(
496
+ 999999999,
497
+ '%#%',
498
+ add_query_arg(
499
+ array('paged' => 999999999),
500
+ Helper::getPluginAdminUrl()
501
+ )
502
+ ),
503
+ 'format' => '?paged=%#%',
504
+ 'current' => max(1, $paged),
505
+ 'total' => $numberOfPages,
506
+ 'prev_text' => '&lsaquo;',
507
+ 'next_text' => '&rsaquo;',
508
+ 'before_page_number' => '<span>',
509
+ 'after_page_number' => '</span>'
510
+ ));
511
+ printf('<span class="wpgdprc-pagination__results">%s</span>', sprintf(__('%d of %d results found', WP_GDPR_C_SLUG), count($requests), $total));
512
+ ?>
513
+ </div>
514
+ <?php
515
+ else :
516
+ ?>
517
+ <p><strong><?php _e('No requests found.', WP_GDPR_C_SLUG); ?></strong></p>
518
+ <?php
519
+ endif;
520
+ }
521
+
522
+ /**
523
+ * @return null|Page
524
+ */
525
+ public static function getInstance() {
526
+ if (!isset(self::$instance)) {
527
+ self::$instance = new self();
528
+ }
529
+ return self::$instance;
530
+ }
531
+ }
Includes/Pages.php DELETED
@@ -1,213 +0,0 @@
1
- <?php
2
-
3
- namespace WPGDPRC\Includes;
4
-
5
- /**
6
- * Class Pages
7
- * @package WPGDPRC\Includes
8
- */
9
- class Pages {
10
- /** @var null */
11
- private static $instance = null;
12
-
13
- public function registerSettings() {
14
- foreach (Helpers::getCheckList() as $id => $check) {
15
- register_setting(WP_GDPR_C_SLUG, WP_GDPR_C_PREFIX . '_general_' . $id, 'intval');
16
- }
17
- register_setting(WP_GDPR_C_SLUG, WP_GDPR_C_PREFIX . '_settings_privacy_policy_page', 'intval');
18
- register_setting(WP_GDPR_C_SLUG, WP_GDPR_C_PREFIX . '_settings_privacy_policy_text', array('sanitize_callback' => array(Helpers::getInstance(), 'sanitizeData')));
19
- }
20
-
21
- public function addAdminMenu() {
22
- $pluginData = Helpers::getPluginData();
23
- add_submenu_page(
24
- 'tools.php',
25
- $pluginData['Name'],
26
- $pluginData['Name'],
27
- 'manage_options',
28
- str_replace('-', '_', WP_GDPR_C_SLUG),
29
- array($this, 'generatePage')
30
- );
31
- }
32
-
33
- public function generatePage() {
34
- $pluginData = Helpers::getPluginData();
35
- $activatedPlugins = Helpers::getActivatedPlugins();
36
- $optionNamePrivacyPolicyPage = WP_GDPR_C_PREFIX . '_settings_privacy_policy_page';
37
- $optionNamePrivacyPolicyText = WP_GDPR_C_PREFIX . '_settings_privacy_policy_text';
38
- $privacyPolicyPage = get_option($optionNamePrivacyPolicyPage);
39
- $privacyPolicyText = esc_html(Integrations::getPrivacyPolicyText());
40
- $daysLeftToComply = Helpers::getDaysLeftToComply();
41
- ?>
42
- <div class="wrap">
43
- <div class="wpgdprc">
44
- <h1 class="wpgdprc-title"><span class="dashicons dashicons-lock"></span> <?php echo $pluginData['Name']; ?></h1>
45
-
46
- <?php settings_errors(); ?>
47
-
48
- <form method="post" action="<?php echo admin_url('options.php'); ?>" novalidate="novalidate">
49
- <?php settings_fields(WP_GDPR_C_SLUG); ?>
50
-
51
- <div class="wpgdprc-tabs">
52
- <div class="wpgdprc-tabs__navigation wpgdprc-clearfix">
53
- <a id="tab-integrations-label" class="active" href="#tab-integrations" aria-controls="tab-integrations" tabindex="0" role="tab"><?php _e('Integrations', WP_GDPR_C_SLUG); ?></a>
54
- <a id="tab-checklist-label" href="#tab-checklist" aria-controls="tab-checklist" tabindex="-1" role="tab"><?php _e('Checklist', WP_GDPR_C_SLUG); ?></a>
55
- <a id="tab-settings-label" href="#tab-settings" aria-controls="tab-settings" tabindex="-1" role="tab"><?php _e('Settings', WP_GDPR_C_SLUG); ?></a>
56
- </div>
57
-
58
- <div class="wpgdprc-tabs__content">
59
- <div id="tab-integrations" class="wpgdprc-tabs__panel active" aria-labelledby="tab-integrations-label" role="tabpanel">
60
- <?php if (!empty($activatedPlugins)) : ?>
61
- <ul class="wpgdprc-list">
62
- <?php
63
- foreach ($activatedPlugins as $key => $plugin) :
64
- $optionName = WP_GDPR_C_PREFIX . '_integrations_' . $plugin['id'];
65
- $checked = Helpers::isEnabled($plugin['id']);
66
- $description = (!empty($plugin['description'])) ? apply_filters('the_content', $plugin['description']) : '';
67
- $notices = Helpers::getNotices($plugin['id']);
68
- $options = Integrations::getSupportedPluginOptions($plugin['id']);
69
- ?>
70
- <li class="wpgdprc-clearfix">
71
- <?php if ($plugin['supported']) : ?>
72
- <?php if (empty($notices)) : ?>
73
- <div class="wpgdprc-checkbox">
74
- <input type="checkbox" name="<?php echo $optionName; ?>" id="<?php echo $optionName; ?>" value="1" tabindex="1" data-type="save_setting" data-option="<?php echo $optionName; ?>" <?php checked(true, $checked); ?> />
75
- <label for="<?php echo $optionName; ?>"><?php echo $plugin['name']; ?></label>
76
- <span class="wpgdprc-instructions"><?php _e('Enable:', WP_GDPR_C_SLUG); ?></span>
77
- <div class="wpgdprc-switch" aria-hidden="true">
78
- <div class="wpgdprc-switch-label">
79
- <div class="wpgdprc-switch-inner"></div>
80
- <div class="wpgdprc-switch-switch"></div>
81
- </div>
82
- </div>
83
- </div>
84
-
85
- <div class="wpgdprc-checkbox-data" <?php if (!$checked) : ?>style="display: none;"<?php endif; ?>>
86
- <?php if (!empty($description)) : ?>
87
- <div class="wpgdprc-checklist-description">
88
- <?php echo $description; ?>
89
- </div>
90
- <?php endif; ?>
91
- <?php echo $options; ?>
92
- </div>
93
- <?php else : ?>
94
- <div class="wpgdrc-message wpgdrc-message--notice">
95
- <strong><?php echo $plugin['name']; ?></strong>
96
- <div class="wpgdprc__message">
97
- <?php echo $notices; ?>
98
- </div>
99
- </div>
100
- <?php endif; ?>
101
- <?php else : ?>
102
- <div class="wpgdrc-message wpgdrc-message--error">
103
- <strong><?php echo $plugin['name']; ?></strong>
104
- <div class="wpgdprc__message">
105
- <?php printf(__('This plugin is outdated. %s supports version %s and up.', WP_GDPR_C_SLUG), $pluginData['Name'], '<strong>' . $plugin['supported_version'] . '</strong>'); ?>
106
- </div>
107
- </div>
108
- <?php endif; ?>
109
- </li>
110
- <?php
111
- endforeach;
112
- ?>
113
- </ul>
114
- <?php else : ?>
115
- <p><strong><?php _e('Couldn\'t find any supported plugins installed.', WP_GDPR_C_SLUG); ?></strong></p>
116
- <p><?php _e('The following plugins are supported as of now:', WP_GDPR_C_SLUG); ?></p>
117
- <ul class="ul-square">
118
- <?php foreach (Integrations::getSupportedPlugins() as $plugin) : ?>
119
- <li><?php echo $plugin['name']; ?></li>
120
- <?php endforeach; ?>
121
- </ul>
122
- <p><?php _e('More plugins will be added in the future.', WP_GDPR_C_SLUG); ?></p>
123
- <?php endif; ?>
124
- </div>
125
- <div id="tab-checklist" class="wpgdprc-tabs__panel" aria-hidden="true" aria-labelledby="tab-checklist-label" role="tabpanel">
126
- <p><?php _e('Below we ask you what private data you currently collect and provide you with tips to comply.', WP_GDPR_C_SLUG); ?></p>
127
- <ul class="wpgdprc-list">
128
- <?php
129
- foreach (Helpers::getCheckList() as $id => $check) :
130
- $optionName = WP_GDPR_C_PREFIX . '_general_' . $id;
131
- $checked = Helpers::isEnabled($id, 'general');
132
- $description = (!empty($check['description'])) ? esc_html($check['description']) : '';
133
- ?>
134
- <li class="wpgdprc-clearfix">
135
- <div class="wpgdprc-checkbox">
136
- <input type="checkbox" name="<?php echo $optionName; ?>" id="<?php echo $id; ?>" value="1" tabindex="1" data-type="save_setting" data-option="<?php echo $optionName; ?>" <?php checked(true, $checked); ?> />
137
- <label for="<?php echo $id; ?>"><?php echo $check['label']; ?></label>
138
- <div class="wpgdprc-switch wpgdprc-switch--reverse" aria-hidden="true">
139
- <div class="wpgdprc-switch-label">
140
- <div class="wpgdprc-switch-inner"></div>
141
- <div class="wpgdprc-switch-switch"></div>
142
- </div>
143
- </div>
144
- </div>
145
-
146
- <?php if (!empty($description)) : ?>
147
- <div class="wpgdprc-checkbox-data" <?php if (!$checked) : ?>style="display: none;"<?php endif; ?>>
148
- <div class="wpgdprc-checklist-description">
149
- <?php echo $description; ?>
150
- </div>
151
- </div>
152
- <?php endif; ?>
153
- </li>
154
- <?php
155
- endforeach;
156
- ?>
157
- </ul>
158
- </div>
159
- <div id="tab-settings" class="wpgdprc-tabs__panel" aria-hidden="true" aria-labelledby="tab-settings-label" role="tabpanel">
160
- <p><?php _e('Use %privacy_policy% if you want to link your Privacy Policy page in the GDPR checkbox texts.', WP_GDPR_C_SLUG); ?></p>
161
- <p class="wpgdprc-setting">
162
- <label for="<?php echo $optionNamePrivacyPolicyPage; ?>"><?php _e('Privacy Policy', WP_GDPR_C_SLUG); ?></label>
163
- <?php
164
- wp_dropdown_pages(array(
165
- 'show_option_none' => __('Select an option', WP_GDPR_C_SLUG),
166
- 'name' => $optionNamePrivacyPolicyPage,
167
- 'selected' => $privacyPolicyPage
168
- ));
169
- ?>
170
- </p>
171
- <p class="wpgdprc-setting">
172
- <label for="<?php echo $optionNamePrivacyPolicyText; ?>"><?php _e('Link text', WP_GDPR_C_SLUG); ?></label>
173
- <input type="text" name="<?php echo $optionNamePrivacyPolicyText; ?>" class="regular-text" id="<?php echo $optionNamePrivacyPolicyText; ?>" placeholder="<?php echo $privacyPolicyText; ?>" value="<?php echo $privacyPolicyText; ?>" />
174
- </p>
175
- </div>
176
- </div>
177
- </div>
178
-
179
- <?php submit_button(); ?>
180
- </form>
181
-
182
- <div class="wpgdprc-description">
183
- <p><?php printf(__('This plugin assists website and webshop owners to comply with European privacy regulations known as GDPR. By May 24th, 2018 your site or shop has to comply to avoid large fines. The regulation can be read here: %s.', WP_GDPR_C_SLUG), '<a target="_blank" href="//www.eugdpr.org/the-regulation.html">' . __('GDPR Key Changes', WP_GDPR_C_SLUG) . '</a>'); ?></p>
184
- <p><?php printf(__('%s currently supports %s.', WP_GDPR_C_SLUG), $pluginData['Name'], implode(', ', Integrations::getSupportedIntegrationsLabels())); ?></p>
185
- </div>
186
-
187
- <p class="wpgdprc-disclaimer"><?php _e('Disclaimer: The creators of this plugin do not have a legal background please contact a law firm for rock solid legal advice.', WP_GDPR_C_SLUG); ?></p>
188
-
189
- <?php if ($daysLeftToComply > 0) : ?>
190
- <div class="wpgdprc-countdown">
191
- <div class="wpgdprc-countdown-inner">
192
- <h2><?php echo date(get_option('date_format'), strtotime('25 May 2018')); ?></h2>
193
- <p><?php printf(__('You have %s left to comply with GDPR.', WP_GDPR_C_SLUG), sprintf(_n('%s day', '%s days', $daysLeftToComply, WP_GDPR_C_SLUG), number_format_i18n($daysLeftToComply))); ?></p>
194
- </div>
195
- </div>
196
- <?php endif; ?>
197
-
198
- <div class="wpgdprc-background"><?php include(WP_GDPR_C_DIR_SVG . '/inline-waves.svg.php'); ?></div>
199
- </div>
200
- </div>
201
- <?php
202
- }
203
-
204
- /**
205
- * @return null|Pages
206
- */
207
- public static function getInstance() {
208
- if (!isset(self::$instance)) {
209
- self::$instance = new self();
210
- }
211
- return self::$instance;
212
- }
213
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Includes/SessionHelper.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WPGDPRC\Includes;
4
+
5
+ /**
6
+ * Class SessionHelper
7
+ * @package WPGDPRC\Includes
8
+ */
9
+ class SessionHelper {
10
+ /**
11
+ * @return string
12
+ */
13
+ public static function getSessionId() {
14
+ self::startSession();
15
+ return session_id();
16
+ }
17
+
18
+ /**
19
+ * Start the session if it has not started yet
20
+ */
21
+ public static function startSession() {
22
+ if (!session_id()) {
23
+ @session_start();
24
+ }
25
+ }
26
+
27
+ /**
28
+ * @param string $sessionId
29
+ * @return bool
30
+ */
31
+ public static function checkSession($sessionId = '') {
32
+ return self::getSessionId() === $sessionId;
33
+ }
34
+
35
+ /**
36
+ * @param string $variable
37
+ * @param string $value
38
+ */
39
+ public static function setSessionVariable($variable = '', $value = '') {
40
+ self::startSession();
41
+ $_SESSION[$variable] = $value;
42
+ }
43
+
44
+ /**
45
+ * @param string $variable
46
+ * @return bool
47
+ */
48
+ public static function getSessionVariable($variable = '') {
49
+ self::startSession();
50
+ return (isset($_SESSION[$variable])) ? $_SESSION[$variable] : false;
51
+ }
52
+ }
Includes/Shortcode.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WPGDPRC\Includes;
4
+
5
+ /**
6
+ * Class Shortcode
7
+ * @package WPGDPRC\Includes
8
+ */
9
+ class Shortcode {
10
+ /** @var null */
11
+ private static $instance = null;
12
+
13
+ /**
14
+ * @return string
15
+ */
16
+ private static function getAccessRequestData() {
17
+ $output = '';
18
+ $request = (isset($_REQUEST['wpgdprc'])) ? unserialize(base64_decode(esc_html($_REQUEST['wpgdprc']))) : false;
19
+ $request = (!empty($request)) ? AccessRequest::getInstance()->getByEmailAddressAndSessionId($request['email'], $request['sId']) : false;
20
+ if ($request !== false) {
21
+ if (
22
+ SessionHelper::checkSession($request->getSessionId()) &&
23
+ Helper::checkIpAddress($request->getIpAddress())
24
+ ) {
25
+ $data = new Data($request->getEmailAddress());
26
+ $users = Data::getOutput($data->getUsers(), 'user', $request->getId());
27
+ $comments = Data::getOutput($data->getComments(), 'comment', $request->getId());
28
+ $woocommerceOrders = Data::getOutput($data->getWooCommerceOrders(), 'woocommerce_order', $request->getId());
29
+ $output .= sprintf(
30
+ '<div class="wpgdprc-feedback wpgdprc-feedback--notice">%s</div>',
31
+ Integration::getDeleteRequestFormExplanationText()
32
+ );
33
+ $output .= sprintf('<h2 class="wpgdprc-title">%s</h2>', __('Users', WP_GDPR_C_SLUG));
34
+ if (!empty($users)) {
35
+ $output .= $users;
36
+ } else {
37
+ $output .= sprintf(
38
+ '<div class="wpgdprc-feedback wpgdprc-feedback--notice">%s</div>',
39
+ sprintf(
40
+ __('No users found with email address %s.', WP_GDPR_C_SLUG),
41
+ sprintf('<strong>%s</strong>', $request->getEmailAddress())
42
+ )
43
+ );
44
+ }
45
+ $output .= sprintf('<h2 class="wpgdprc-title">%s</h2>', __('Comments', WP_GDPR_C_SLUG));
46
+ if (!empty($comments)) {
47
+ $output .= $comments;
48
+ } else {
49
+ $output .= sprintf(
50
+ '<div class="wpgdprc-feedback wpgdprc-feedback--notice">%s</div>',
51
+ sprintf(
52
+ __('No comments found with email address %s.', WP_GDPR_C_SLUG),
53
+ sprintf('<strong>%s</strong>', $request->getEmailAddress())
54
+ )
55
+ );
56
+ }
57
+ $output .= sprintf('<h2 class="wpgdprc-title">%s</h2>', __('WooCommerce Orders', WP_GDPR_C_SLUG));
58
+ if (!empty($woocommerceOrders)) {
59
+ $output .= $woocommerceOrders;
60
+ } else {
61
+ $output .= sprintf(
62
+ '<div class="wpgdprc-feedback wpgdprc-feedback--notice">%s</div>',
63
+ sprintf(
64
+ __('No WooCommerce orders found with email address %s.', WP_GDPR_C_SLUG),
65
+ sprintf('<strong>%s</strong>', $request->getEmailAddress())
66
+ )
67
+ );
68
+ }
69
+ } else {
70
+ wp_die(
71
+ '<p>' . sprintf(
72
+ __('<strong>ERROR</strong>: %s', WP_GDPR_C_SLUG),
73
+ __('What are you trying to do?', WP_GDPR_C_SLUG)
74
+ ) . '</p>'
75
+ );
76
+ exit;
77
+ }
78
+ } else {
79
+ $output .= __('This request is expired or doesn\'t exist.', WP_GDPR_C_SLUG);
80
+ }
81
+ return $output;
82
+ }
83
+
84
+ /**
85
+ * @return string
86
+ */
87
+ public function accessRequestForm() {
88
+ wp_enqueue_style('wpgdprc.css');
89
+ wp_enqueue_script('wpgdprc.js');
90
+ $page = Helper::getAccessRequestPage();
91
+ if (!empty($page) && (get_queried_object_id() !== $page->ID)) {
92
+ return '';
93
+ }
94
+ $output = '<div class="wpgdprc">';
95
+ if (isset($_REQUEST['wpgdprc'])) {
96
+ $output .= self::getAccessRequestData();
97
+ } else {
98
+ $output .= '<form class="wpgdprc-form wpgdprc-form--access-request" name="wpgdprc_form" method="POST">';
99
+ $output .= apply_filters('wpgdprc_request_form_email_field', '<p><input type="email" name="wpgdprc_email" id="wpgdprc-form__email" placeholder="' . esc_attr__(apply_filters('wpgdprc_request_form_email_placeholder', __('Your Email Address', WP_GDPR_C_SLUG))) . '" required /></p>');
100
+ $output .= apply_filters(
101
+ 'wpgdprc_request_form_consent_field',
102
+ sprintf(
103
+ '<p><input type="checkbox" name="wpgdprc_consent" id="wpgdprc-form__consent" value="1" required /> %s</p>',
104
+ Integration::getAccessRequestFormCheckboxText()
105
+ )
106
+ );
107
+ $output .= apply_filters('wpgdprc_request_form_submit_field', '<p><input type="submit" name="wpgdprc_submit" value="' . esc_attr__(apply_filters('wpgdprc_request_form_submit_label', __('Send', WP_GDPR_C_SLUG))) . '" /></p>');
108
+ $output .= '<div class="wpgdprc-feedback" style="display: none;"></div>';
109
+ $output .= '</form>';
110
+ }
111
+ $output .= '</div>';
112
+ return apply_filters('wpgdprc_request_form', $output);
113
+ }
114
+
115
+ /**
116
+ * @return null|Shortcode
117
+ */
118
+ public static function getInstance() {
119
+ if (!isset(self::$instance)) {
120
+ self::$instance = new self();
121
+ }
122
+ return self::$instance;
123
+ }
124
+ }
assets/css/admin.css CHANGED
@@ -66,35 +66,61 @@
66
  font-style: normal;
67
  }
68
 
69
- div.wpgdprc-allowed-tags {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  font-size: 12px;
71
  color: #8A8A8A;
72
  }
73
 
74
- div.wpgdrc-message {
75
  padding: 10px;
76
  border: 1px solid transparent;
77
  }
78
 
79
- div.wpgdrc-message--notice {
80
- background: #FFF3D9;
81
- border-color: #e7d996;
82
  }
83
 
84
- div.wpgdrc-message--notice .wpgdprc__message {
85
- color: #b39f3d;
 
86
  }
87
 
88
- div.wpgdrc-message--error {
89
  background: #F7E4E1;
90
  border-color: #CC4B37;
 
91
  }
92
 
93
- div.wpgdrc-message--error .wpgdprc__message {
94
- color: #CC4B37;
 
 
 
 
 
95
  }
96
 
97
- .wpgdprc p.submit .button.button-primary {
98
  vertical-align: top;
99
  height: 34px;
100
  background: #4AA94F;
@@ -117,14 +143,8 @@ h1.wpgdprc-title {
117
  font-size: 36px;
118
  }
119
 
120
- h1.wpgdprc-title .dashicons {
121
- width: inherit;
122
- height: inherit;
123
- font-size: inherit;
124
- color: #4AA94F;
125
- }
126
-
127
  div.wpgdprc-description {
 
128
  padding: 10px;
129
  background: #F1F1F1;
130
  }
@@ -142,6 +162,25 @@ p.wpgdprc-disclaimer {
142
  color: #8A8A8A;
143
  }
144
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  .wpgdprc-background {
146
  position: fixed;
147
  right: 0;
@@ -154,15 +193,12 @@ p.wpgdprc-disclaimer {
154
  fill: #4AA94F;
155
  }
156
 
157
- .wpgdprc-tabs {
158
- position: relative;
159
- }
160
-
161
- .wpgdprc-tabs__navigation {
162
- border-bottom: 1px solid #dbd6d6;
163
  }
164
 
165
- .wpgdprc-tabs__navigation > a {
 
166
  display: block;
167
  float: left;
168
  margin-bottom: -1px;
@@ -179,27 +215,39 @@ p.wpgdprc-disclaimer {
179
  color: inherit;
180
  }
181
 
182
- .wpgdprc-tabs__navigation > a.active {
183
  background-color: #fff;
184
  color: #4AA94F;
185
- border-top-color: #dbd6d6;
186
- border-right-color: #dbd6d6;
187
- border-left-color: #dbd6d6;
188
  }
189
 
190
- .wpgdprc-tabs__panel {
191
- display: none;
 
 
 
 
 
 
 
 
 
 
 
 
192
  }
193
 
194
- .wpgdprc-tabs__panel.active {
195
  display: block;
196
  background-color: #fff;
197
- border: 1px solid #dbd6d6;
198
  border-top: none;
199
  padding: 20px;
200
  }
201
 
202
- .wpgdprc-tabs__panel > p:first-child {
203
  margin-top: 0;
204
  }
205
 
@@ -350,7 +398,7 @@ span.wpgdprc-instructions {
350
  color: #8A8A8A;
351
  }
352
 
353
- .wpgdprc-checklist-description + .wpgdrc-message {
354
  margin-top: 10px;
355
  }
356
 
@@ -383,6 +431,7 @@ span.wpgdprc-instructions {
383
  }
384
 
385
  .wpgdprc-setting {
 
386
  *zoom: 1;
387
  }
388
 
@@ -400,7 +449,11 @@ span.wpgdprc-instructions {
400
  vertical-align: top;
401
  }
402
 
403
- .wpgdprc-setting input, .wpgdprc-setting select {
 
 
 
 
404
  margin: 0;
405
  width: 100%;
406
  -webkit-box-shadow: none;
@@ -409,7 +462,7 @@ span.wpgdprc-instructions {
409
  font-size: inherit;
410
  }
411
 
412
- .wpgdprc-setting input {
413
  background-color: #FFFFFF;
414
  }
415
 
@@ -417,6 +470,10 @@ span.wpgdprc-instructions {
417
  background-color: #FAFAFA;
418
  }
419
 
 
 
 
 
420
  .wpgdprc-countdown {
421
  display: table;
422
  margin: 30px auto 0;
@@ -444,6 +501,25 @@ span.wpgdprc-instructions {
444
  margin: 0;
445
  }
446
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
447
  @media screen and (max-width: 639px) {
448
  .wpgdprc-instructions {
449
  display: none;
@@ -461,9 +537,7 @@ span.wpgdprc-instructions {
461
  width: 100%;
462
  max-width: 30%;
463
  }
464
- div.wpgdprc-allowed-tags,
465
- .wpgdprc-setting input,
466
- .wpgdprc-setting select {
467
  float: right;
468
  width: 100%;
469
  max-width: 70%;
66
  font-style: normal;
67
  }
68
 
69
+ .wpgdprc .wpgdprc-status--processing,
70
+ .wpgdprc .wpgdprc-status--removed {
71
+ pointer-events: none;
72
+ }
73
+
74
+ .wpgdprc .wpgdprc-status--processing {
75
+ opacity: .5;
76
+ }
77
+
78
+ .wpgdprc .wpgdprc-status--removed {
79
+ opacity: .2;
80
+ text-decoration: line-through;
81
+ }
82
+
83
+ .wpgdprc .wpgdprc-status--error {
84
+ background-color: #F7E4E1;
85
+ border-color: #CC4B37;
86
+ color: #CC4B37;
87
+ }
88
+
89
+ div.wpgdprc-information {
90
  font-size: 12px;
91
  color: #8A8A8A;
92
  }
93
 
94
+ div.wpgdprc-message {
95
  padding: 10px;
96
  border: 1px solid transparent;
97
  }
98
 
99
+ div.wpgdprc-message p:first-child {
100
+ margin-top: 0;
 
101
  }
102
 
103
+ div.wpgdprc-message--notice {
104
+ background: #FFF3D9;
105
+ border-color: #E7D996;
106
  }
107
 
108
+ div.wpgdprc-message--error {
109
  background: #F7E4E1;
110
  border-color: #CC4B37;
111
+ color: #CC4B37;
112
  }
113
 
114
+ div.wpgdprc-message + form.wpgdprc-form {
115
+ margin-top: 20px;
116
+ }
117
+
118
+ .wpgdprc p.submit {
119
+ padding-top: 0;
120
+ padding-bottom: 0;
121
  }
122
 
123
+ .wpgdprc .button.button-primary {
124
  vertical-align: top;
125
  height: 34px;
126
  background: #4AA94F;
143
  font-size: 36px;
144
  }
145
 
 
 
 
 
 
 
 
146
  div.wpgdprc-description {
147
+ margin-top: 20px;
148
  padding: 10px;
149
  background: #F1F1F1;
150
  }
162
  color: #8A8A8A;
163
  }
164
 
165
+ table.wpgdprc-table {
166
+ width: 100%;
167
+ border: 1px solid #DBD6D6;
168
+ table-layout: fixed;
169
+ }
170
+
171
+ table.wpgdprc-table th, table.wpgdprc-table td {
172
+ padding: 5px;
173
+ }
174
+
175
+ table.wpgdprc-table th {
176
+ background-color: #DBD6D6;
177
+ text-align: start;
178
+ }
179
+
180
+ table.wpgdprc-table tr:nth-child(even) {
181
+ background-color: #F1F1F1;
182
+ }
183
+
184
  .wpgdprc-background {
185
  position: fixed;
186
  right: 0;
193
  fill: #4AA94F;
194
  }
195
 
196
+ .wpgdprc-navigation {
197
+ border-bottom: 1px solid #DBD6D6;
 
 
 
 
198
  }
199
 
200
+ .wpgdprc-navigation > a {
201
+ position: relative;
202
  display: block;
203
  float: left;
204
  margin-bottom: -1px;
215
  color: inherit;
216
  }
217
 
218
+ .wpgdprc-navigation > a.wpgdprc-active {
219
  background-color: #fff;
220
  color: #4AA94F;
221
+ border-top-color: #DBD6D6;
222
+ border-right-color: #DBD6D6;
223
+ border-left-color: #DBD6D6;
224
  }
225
 
226
+ .wpgdprc-navigation span.wpgdprc-badge {
227
+ position: absolute;
228
+ top: -5px;
229
+ right: -5px;
230
+ display: block;
231
+ width: 20px;
232
+ height: 20px;
233
+ background-color: #4AA94F;
234
+ border-radius: 50%;
235
+ text-align: center;
236
+ line-height: 20px;
237
+ font-size: 11px;
238
+ color: #FFFFFF;
239
+ z-index: 1;
240
  }
241
 
242
+ .wpgdprc-content {
243
  display: block;
244
  background-color: #fff;
245
+ border: 1px solid #DBD6D6;
246
  border-top: none;
247
  padding: 20px;
248
  }
249
 
250
+ .wpgdprc-content > p:first-child {
251
  margin-top: 0;
252
  }
253
 
398
  color: #8A8A8A;
399
  }
400
 
401
+ .wpgdprc-checklist-description + .wpgdprc-message {
402
  margin-top: 10px;
403
  }
404
 
431
  }
432
 
433
  .wpgdprc-setting {
434
+ margin: 1em 0;
435
  *zoom: 1;
436
  }
437
 
449
  vertical-align: top;
450
  }
451
 
452
+ .wpgdprc-setting label input[type="checkbox"] {
453
+ margin-top: 0 !important;
454
+ }
455
+
456
+ .wpgdprc-setting input[type="text"], .wpgdprc-setting textarea, .wpgdprc-setting select {
457
  margin: 0;
458
  width: 100%;
459
  -webkit-box-shadow: none;
462
  font-size: inherit;
463
  }
464
 
465
+ .wpgdprc-setting input[type="text"], .wpgdprc-setting textarea {
466
  background-color: #FFFFFF;
467
  }
468
 
470
  background-color: #FAFAFA;
471
  }
472
 
473
+ .wpgdprc-setting .wpgdprc-information {
474
+ margin-top: .5em;
475
+ }
476
+
477
  .wpgdprc-countdown {
478
  display: table;
479
  margin: 30px auto 0;
501
  margin: 0;
502
  }
503
 
504
+ .wpgdprc-pagination {
505
+ margin-top: 20px;
506
+ line-height: 28px;
507
+ }
508
+
509
+ .wpgdprc-pagination .page-numbers {
510
+ display: inline-block;
511
+ vertical-align: top;
512
+ width: 30px;
513
+ background-color: #FFFFFF;
514
+ border: 1px solid #DBD6D6;
515
+ text-align: center;
516
+ text-decoration: none;
517
+ }
518
+
519
+ .wpgdprc-pagination .page-numbers + .wpgdprc-pagination__results {
520
+ margin-left: 10px;
521
+ }
522
+
523
  @media screen and (max-width: 639px) {
524
  .wpgdprc-instructions {
525
  display: none;
537
  width: 100%;
538
  max-width: 30%;
539
  }
540
+ .wpgdprc-options {
 
 
541
  float: right;
542
  width: 100%;
543
  max-width: 70%;
assets/css/front.css ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .wpgdprc .wpgdprc-status--processing,
2
+ .wpgdprc .wpgdprc-status--removed {
3
+ pointer-events: none;
4
+ }
5
+
6
+ .wpgdprc .wpgdprc-status--processing {
7
+ opacity: .5;
8
+ }
9
+
10
+ .wpgdprc .wpgdprc-status--removed {
11
+ opacity: .2;
12
+ text-decoration: line-through;
13
+ }
14
+
15
+ .wpgdprc .wpgdprc-status--error {
16
+ background-color: #F7E4E1;
17
+ border-color: #CC4B37;
18
+ color: #CC4B37;
19
+ }
assets/js/admin.js CHANGED
@@ -1,8 +1,7 @@
1
  (function ($, window, document, undefined) {
2
  'use strict';
3
 
4
- var ajaxLoading = false,
5
- ajaxURL = wpgdprcData.ajaxURL,
6
  ajaxSecurity = wpgdprcData.ajaxSecurity,
7
  delay = (function () {
8
  var timer = 0;
@@ -12,39 +11,33 @@
12
  };
13
  })(),
14
  $wpgdprc = $('.wpgdprc'),
15
- $wpgdprcCheckbox = $('.wpgdprc-checkbox input[type="checkbox"]', $wpgdprc),
16
- $wpgdprcTabs = $('.wpgdprc-tabs'),
17
- initCheckboxes = function () {
18
- if (!$wpgdprcCheckbox.length) {
19
- return;
20
- }
21
- $wpgdprcCheckbox.on('change', function (e) {
22
- e.preventDefault();
23
- doProcessAction($(this));
24
- });
25
- },
26
- initTabs = function () {
27
- if (!$wpgdprcTabs.length) {
28
- return;
 
 
 
 
29
  }
30
- var $wpgdprcTabsNavigation = $('.wpgdprc-tabs__navigation', $wpgdprcTabs),
31
- $wpgdprcTabsNavigationItem = $('a', $wpgdprcTabsNavigation),
32
- $wpgdprcTabsPanel = $('.wpgdprc-tabs__panel', $wpgdprcTabs);
33
-
34
- $wpgdprcTabsNavigationItem.on('click', function (e) {
35
- e.preventDefault();
36
- var target = $(this).attr('href'),
37
- $target = $(target);
38
- if (!$target.length) {
39
- return;
40
- }
41
- $wpgdprcTabsNavigationItem.removeClass('active').attr('aria-selected', false).attr('tabindex', '-1');
42
- $wpgdprcTabsPanel.removeClass('active').attr('aria-hidden', true);
43
- $(this).addClass('active').attr('aria-selected', true).attr('tabindex', 0);
44
- $target.addClass('active').attr('aria-hidden', false);
45
- });
46
  },
47
- getElementAjaxData = function ($element) {
 
 
 
 
 
48
  var data = $element.data();
49
  if (!data.option) {
50
  data.option = $element.attr('name');
@@ -57,12 +50,14 @@
57
  }
58
  return data;
59
  },
60
- doProcessAction = function ($element) {
 
 
 
 
61
  $element.addClass('processing');
62
-
63
- var $wpgdprcCheckboxContainer = $element.closest('.wpgdprc-checkbox'),
64
- $wpgdprcCheckboxData = ($wpgdprcCheckboxContainer.length) ? $wpgdprcCheckboxContainer.next('.wpgdprc-checkbox-data') : false;
65
-
66
  $.ajax({
67
  url: ajaxURL,
68
  type: 'POST',
@@ -70,15 +65,15 @@
70
  data: {
71
  action: 'wpgdprc_process_action',
72
  security: ajaxSecurity,
73
- data: getElementAjaxData($element)
74
  },
75
  success: function (response) {
76
  if (response) {
77
- if ($wpgdprcCheckboxData.length) {
78
  if ($element.is(':checked')) {
79
- $wpgdprcCheckboxData.stop(true, true).slideDown('fast');
80
  } else {
81
- $wpgdprcCheckboxData.stop(true, true).slideUp('fast');
82
  }
83
  }
84
 
@@ -98,6 +93,82 @@
98
  }, 2000);
99
  }
100
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  };
102
 
103
  $(function () {
@@ -105,6 +176,7 @@
105
  return;
106
  }
107
  initCheckboxes();
108
- initTabs();
 
109
  });
110
  })(jQuery, window, document);
1
  (function ($, window, document, undefined) {
2
  'use strict';
3
 
4
+ var ajaxURL = wpgdprcData.ajaxURL,
 
5
  ajaxSecurity = wpgdprcData.ajaxSecurity,
6
  delay = (function () {
7
  var timer = 0;
11
  };
12
  })(),
13
  $wpgdprc = $('.wpgdprc'),
14
+ $checkbox = $('input[type="checkbox"]', $('.wpgdprc-checkbox, .wpgdprc-setting', $wpgdprc)),
15
+ $selectAll = $('.wpgdprc-select-all', $wpgdprc),
16
+ $formProcessDeleteRequests = $('.wpgdprc-form--process-delete-requests'),
17
+ /**
18
+ * @param $checkboxes
19
+ * @returns {Array}
20
+ * @private
21
+ */
22
+ _getValuesByCheckedBoxes = function ($checkboxes) {
23
+ var output = [];
24
+ if ($checkboxes.length) {
25
+ $checkboxes.each(function () {
26
+ var $this = $(this),
27
+ value = $this.val();
28
+ if ($this.is(':checked') && value > 0) {
29
+ output.push(value);
30
+ }
31
+ });
32
  }
33
+ return output;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  },
35
+ /**
36
+ * @param $element
37
+ * @returns {*}
38
+ * @private
39
+ */
40
+ _getElementAjaxData = function ($element) {
41
  var data = $element.data();
42
  if (!data.option) {
43
  data.option = $element.attr('name');
50
  }
51
  return data;
52
  },
53
+ /**
54
+ * @param $element
55
+ * @private
56
+ */
57
+ _doProcessAction = function ($element) {
58
  $element.addClass('processing');
59
+ var $checkboxContainer = $element.closest('.wpgdprc-checkbox'),
60
+ $checkboxData = ($checkboxContainer.length) ? $checkboxContainer.next('.wpgdprc-checkbox-data') : false;
 
 
61
  $.ajax({
62
  url: ajaxURL,
63
  type: 'POST',
65
  data: {
66
  action: 'wpgdprc_process_action',
67
  security: ajaxSecurity,
68
+ data: _getElementAjaxData($element)
69
  },
70
  success: function (response) {
71
  if (response) {
72
+ if ($checkboxData.length) {
73
  if ($element.is(':checked')) {
74
+ $checkboxData.stop(true, true).slideDown('fast');
75
  } else {
76
+ $checkboxData.stop(true, true).slideUp('fast');
77
  }
78
  }
79
 
93
  }, 2000);
94
  }
95
  });
96
+ },
97
+ _ajax = function (values, $form, delay) {
98
+ var value = values.slice(0, 1);
99
+ if (value.length > 0) {
100
+ var $feedback = $('.wpgdprc-feedback', $form),
101
+ $row = $('tr[data-id="' + value[0] + '"]', $form);
102
+ $row.removeClass('wpgdprc-status--error');
103
+ $row.addClass('wpgdprc-status--processing');
104
+ $feedback.attr('style', 'display: none;');
105
+ $feedback.removeClass('wpgdprc-feedback--error');
106
+ $feedback.empty();
107
+ setTimeout(function () {
108
+ $.ajax({
109
+ url: ajaxURL,
110
+ type: 'POST',
111
+ dataType: 'JSON',
112
+ data: {
113
+ action: 'wpgdprc_process_delete_request',
114
+ security: ajaxSecurity,
115
+ data: {
116
+ id: value[0]
117
+ }
118
+ },
119
+ success: function (response) {
120
+ if (response) {
121
+ $row.removeClass('wpgdprc-status--processing');
122
+ if (response.error) {
123
+ $row.addClass('wpgdprc-status--error');
124
+ $feedback.html(response.error);
125
+ $feedback.addClass('wpgdprc-feedback--error');
126
+ $feedback.removeAttr('style');
127
+ } else {
128
+ values.splice(0, 1);
129
+ $('input[type="checkbox"]', $row).remove();
130
+ $row.addClass('wpgdprc-status--removed');
131
+ $('.dashicons-no', $row).removeClass('dashicons-no').addClass('dashicons-yes');
132
+ _ajax(values, $form, 500);
133
+
134
+ }
135
+ }
136
+ }
137
+ });
138
+ }, (delay || 0));
139
+ }
140
+ },
141
+ initCheckboxes = function () {
142
+ if (!$checkbox.length) {
143
+ return;
144
+ }
145
+ $checkbox.on('change', function (e) {
146
+ e.preventDefault();
147
+ _doProcessAction($(this));
148
+ });
149
+ },
150
+ initSelectAll = function () {
151
+ if (!$selectAll.length) {
152
+ return;
153
+ }
154
+ $selectAll.on('change', function () {
155
+ var $this = $(this),
156
+ checked = $this.is(':checked'),
157
+ $checkboxes = $('tbody input[type="checkbox"]', $this.closest('table'));
158
+ $checkboxes.prop('checked', checked);
159
+ });
160
+ },
161
+ initProcessDeleteRequests = function () {
162
+ if (!$formProcessDeleteRequests.length) {
163
+ return;
164
+ }
165
+ $formProcessDeleteRequests.on('submit', function (e) {
166
+ e.preventDefault();
167
+ var $this = $(this),
168
+ $checkboxes = $('.wpgdprc-checkbox', $this);
169
+ $selectAll.prop('checked', false);
170
+ _ajax(_getValuesByCheckedBoxes($checkboxes), $this);
171
+ });
172
  };
173
 
174
  $(function () {
176
  return;
177
  }
178
  initCheckboxes();
179
+ initSelectAll();
180
+ initProcessDeleteRequests();
181
  });
182
  })(jQuery, window, document);
assets/js/front.js ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function (window, document, undefined) {
2
+ 'use strict';
3
+
4
+ /**
5
+ * @param data
6
+ * @returns {string}
7
+ * @private
8
+ */
9
+ var _objectToParametersString = function (data) {
10
+ return Object.keys(data).map(function (key) {
11
+ var value = data[key];
12
+ if (typeof value === 'object') {
13
+ value = JSON.stringify(value);
14
+ }
15
+ return key + '=' + value;
16
+ }).join('&');
17
+ },
18
+ /**
19
+ * @param $checkboxes
20
+ * @returns {Array}
21
+ * @private
22
+ */
23
+ _getValuesByCheckedBoxes = function ($checkboxes) {
24
+ var output = [];
25
+ if ($checkboxes.length) {
26
+ $checkboxes.forEach(function (e) {
27
+ var value = parseInt(e.value);
28
+ if (e.checked && value > 0) {
29
+ output.push(value);
30
+ }
31
+ });
32
+ }
33
+ return output;
34
+ },
35
+ ajaxLoading = false,
36
+ ajaxURL = wpgdprcData.ajaxURL,
37
+ ajaxSecurity = wpgdprcData.ajaxSecurity,
38
+ /**
39
+ * @param data
40
+ * @param values
41
+ * @param $form
42
+ * @param delay
43
+ * @private
44
+ */
45
+ _ajax = function (data, values, $form, delay) {
46
+ var $feedback = $form.querySelector('.wpgdprc-feedback'),
47
+ value = values.slice(0, 1);
48
+ if (value.length > 0) {
49
+ var $row = $form.querySelector('tr[data-id="' + value[0] + '"]');
50
+ $row.classList.remove('wpgdprc-status--error');
51
+ $row.classList.add('wpgdprc-status--processing');
52
+ $feedback.setAttribute('style', 'display: none;');
53
+ $feedback.classList.remove('wpgdprc-feedback--error');
54
+ $feedback.innerHTML = '';
55
+ setTimeout(function () {
56
+ var request = new XMLHttpRequest();
57
+ data.data.value = value[0];
58
+ request.open('POST', ajaxURL);
59
+ request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=UTF-8');
60
+ request.send(_objectToParametersString(data));
61
+ request.addEventListener('load', function () {
62
+ if (request.response) {
63
+ var response = JSON.parse(request.response);
64
+ $row.classList.remove('wpgdprc-status--processing');
65
+ if (response.error) {
66
+ $row.classList.add('wpgdprc-status--error');
67
+ $feedback.innerHTML = response.error;
68
+ $feedback.classList.add('wpgdprc-feedback--error');
69
+ $feedback.removeAttribute('style');
70
+ } else {
71
+ values.splice(0, 1);
72
+ $row.querySelector('input[type="checkbox"]').remove();
73
+ $row.classList.add('wpgdprc-status--removed');
74
+ _ajax(data, values, $form, 500);
75
+ }
76
+ }
77
+ });
78
+ }, (delay || 0));
79
+ }
80
+ };
81
+
82
+ document.addEventListener('DOMContentLoaded', function () {
83
+ var $formAccessRequest = document.querySelector('.wpgdprc-form--access-request'),
84
+ $formDeleteRequest = document.querySelectorAll('.wpgdprc-form--delete-request');
85
+
86
+ if ($formAccessRequest !== null) {
87
+ var $feedback = $formAccessRequest.querySelector('.wpgdprc-feedback'),
88
+ $emailAddress = $formAccessRequest.querySelector('#wpgdprc-form__email'),
89
+ $consent = $formAccessRequest.querySelector('#wpgdprc-form__consent');
90
+
91
+ $formAccessRequest.addEventListener('submit', function (e) {
92
+ e.preventDefault();
93
+ if (!ajaxLoading) {
94
+ ajaxLoading = true;
95
+ $feedback.style.display = 'none';
96
+ $feedback.classList.remove('wpgdprc-feedback--success', 'wpgdprc-feedback--error');
97
+ $feedback.innerHTML = '';
98
+
99
+ var data = {
100
+ action: 'wpgdprc_process_action',
101
+ security: ajaxSecurity,
102
+ data: {
103
+ type: 'access_request',
104
+ email: $emailAddress.value,
105
+ consent: $consent.checked
106
+ }
107
+ },
108
+ request = new XMLHttpRequest();
109
+
110
+ data = _objectToParametersString(data);
111
+ request.open('POST', ajaxURL, true);
112
+ request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=UTF-8');
113
+ request.send(data);
114
+ request.addEventListener('load', function () {
115
+ if (request.response) {
116
+ var response = JSON.parse(request.response);
117
+ if (response.message) {
118
+ $formAccessRequest.reset();
119
+ $emailAddress.blur();
120
+ $feedback.innerHTML = response.message;
121
+ $feedback.classList.add('wpgdprc-feedback--success');
122
+ $feedback.removeAttribute('style');
123
+ }
124
+ if (response.error) {
125
+ $emailAddress.focus();
126
+ $feedback.innerHTML = response.error;
127
+ $feedback.classList.add('wpgdprc-feedback--error');
128
+ $feedback.removeAttribute('style');
129
+ }
130
+ }
131
+ ajaxLoading = false;
132
+ });
133
+ }
134
+ });
135
+ }
136
+
137
+ if ($formDeleteRequest.length > 0) {
138
+ $formDeleteRequest.forEach(function ($form) {
139
+ var $selectAll = $form.querySelector('.wpgdprc-select-all');
140
+
141
+ $form.addEventListener('submit', function (e) {
142
+ e.preventDefault();
143
+ var $this = e.target,
144
+ $checkboxes = $this.querySelectorAll('.wpgdprc-checkbox'),
145
+ data = {
146
+ action: 'wpgdprc_process_action',
147
+ security: ajaxSecurity,
148
+ data: {
149
+ type: 'delete_request',
150
+ session: wpgdprcData.session,
151
+ settings: JSON.parse($this.dataset.wpgdprc)
152
+ }
153
+ };
154
+ $selectAll.checked = false;
155
+ _ajax(data, _getValuesByCheckedBoxes($checkboxes), $this);
156
+ });
157
+
158
+ if ($selectAll !== null) {
159
+ $selectAll.addEventListener('change', function (e) {
160
+ var $this = e.target,
161
+ checked = $this.checked,
162
+ $checkboxes = $form.querySelectorAll('.wpgdprc-checkbox');
163
+ $checkboxes.forEach(function (e) {
164
+ e.checked = checked;
165
+ });
166
+ });
167
+ }
168
+ });
169
+ }
170
+ });
171
+ })(window, document);
languages/wp-gdpr-compliance.pot CHANGED
@@ -1,14 +1,27 @@
 
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP GDPR Compliance\n"
4
- "POT-Creation-Date: 2018-04-03 12:00+0200\n"
5
  "Last-Translator: \n"
6
  "Language-Team: Van Ons <info@van-ons.nl>\n"
7
  "MIME-Version: 1.0\n"
8
  "Content-Type: text/plain; charset=UTF-8\n"
9
  "Content-Transfer-Encoding: 8bit\n"
 
 
 
 
 
 
 
 
10
 
11
- #: Includes/Ajax.php:27
 
 
 
 
12
  msgid "Missing data."
13
  msgstr ""
14
 
@@ -24,9 +37,179 @@ msgstr ""
24
  msgid "Missing value."
25
  msgstr ""
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  #: Includes/Extensions/CF7.php:184 Includes/Extensions/GForms.php:111
28
  #: Includes/Extensions/GForms.php:127 Includes/Extensions/GForms.php:146
29
- #: Includes/Extensions/WC.php:55 Includes/Extensions/WP.php:65
30
  msgid "Not accepted."
31
  msgstr ""
32
 
@@ -43,43 +226,42 @@ msgstr ""
43
  msgid "Accepted on %s."
44
  msgstr ""
45
 
46
- #: Includes/Extensions/WP.php:30
47
- #, php-format
48
- msgid "<strong>ERROR</strong>: %s"
49
  msgstr ""
50
 
51
- #: Includes/Extensions/WP.php:33
52
  msgid "Comment Submission Failure"
53
  msgstr ""
54
 
55
- #: Includes/Extensions/WP.php:53
56
  msgid "GDPR Accepted On"
57
  msgstr ""
58
 
59
- #: Includes/Helpers.php:74
60
  #, php-format
61
  msgid "You can use: %s"
62
  msgstr ""
63
 
64
- #: Includes/Helpers.php:80 Includes/Helpers.php:101
65
  msgid "Note"
66
  msgstr ""
67
 
68
- #: Includes/Helpers.php:81
69
  msgid "No HTML allowed due to plugin limitations."
70
  msgstr ""
71
 
72
- #: Includes/Helpers.php:102
73
  msgid ""
74
  "Please disable the custom comments form in Jetpack to make your WordPress "
75
  "Comments GDPR compliant."
76
  msgstr ""
77
 
78
- #: Includes/Helpers.php:129
79
  msgid "Do you have a contact form?"
80
  msgstr ""
81
 
82
- #: Includes/Helpers.php:130
83
  msgid ""
84
  "Make sure you add a checkbox specifically asking the user of the form if "
85
  "they consent to you storing and using their personal information to get back "
@@ -87,11 +269,11 @@ msgid ""
87
  "if you will send or share the data with any 3rd-parties and which."
88
  msgstr ""
89
 
90
- #: Includes/Helpers.php:133
91
  msgid "Can visitors comment anywhere on your website?"
92
  msgstr ""
93
 
94
- #: Includes/Helpers.php:134
95
  msgid ""
96
  "Make sure you add a checkbox specifically asking the user of the comment "
97
  "section if they consent to storing their message attached to the e-mail "
@@ -100,11 +282,11 @@ msgid ""
100
  "which."
101
  msgstr ""
102
 
103
- #: Includes/Helpers.php:137
104
  msgid "Is there an order form on your website or webshop present?"
105
  msgstr ""
106
 
107
- #: Includes/Helpers.php:138
108
  msgid ""
109
  "Make sure you add a checkbox specifically asking the user of the form if "
110
  "they consent to you storing and using their personal information to ship the "
@@ -114,11 +296,11 @@ msgid ""
114
  "which."
115
  msgstr ""
116
 
117
- #: Includes/Helpers.php:141
118
  msgid "Do you provide a forum or message board?"
119
  msgstr ""
120
 
121
- #: Includes/Helpers.php:142
122
  msgid ""
123
  "Make sure you add a checkbox specifically asking forum / board users if they "
124
  "consent to you storing and using their personal information and messages. "
@@ -126,11 +308,11 @@ msgid ""
126
  "share the data with any 3rd-parties and which."
127
  msgstr ""
128
 
129
- #: Includes/Helpers.php:145
130
  msgid "Can visitors chat with your company directly?"
131
  msgstr ""
132
 
133
- #: Includes/Helpers.php:146
134
  msgid ""
135
  "Make sure you add a checkbox specifically asking chat users if they consent "
136
  "to you storing and using their personal information and messages. The "
@@ -139,161 +321,313 @@ msgid ""
139
  "mention if you will send or share the data with any 3rd-parties and which."
140
  msgstr ""
141
 
142
- #: Includes/Integrations.php:111 Includes/Integrations.php:148
143
  #, php-format
144
  msgid "Form: %s"
145
  msgstr ""
146
 
147
- #: Includes/Integrations.php:112 Includes/Integrations.php:149
148
  msgid "Activate for this form:"
149
  msgstr ""
150
 
151
- #: Includes/Integrations.php:115 Includes/Integrations.php:152
152
- #: Includes/Integrations.php:175
153
  msgid "Checkbox text"
154
  msgstr ""
155
 
156
- #: Includes/Integrations.php:119 Includes/Integrations.php:156
157
- #: Includes/Integrations.php:179
158
  msgid "Error message"
159
  msgstr ""
160
 
161
- #: Includes/Integrations.php:127 Includes/Integrations.php:164
162
  msgid "No forms found."
163
  msgstr ""
164
 
165
- #: Includes/Integrations.php:203
166
  msgid ""
167
  "By using this form you agree with the storage and handling of your data by "
168
  "this website."
169
  msgstr ""
170
 
171
- #: Includes/Integrations.php:220
172
  msgid "Please accept the privacy checkbox."
173
  msgstr ""
174
 
175
- #: Includes/Integrations.php:231 Includes/Pages.php:162
176
  msgid "Privacy Policy"
177
  msgstr ""
178
 
179
- #: Includes/Integrations.php:266
 
 
 
 
 
 
 
 
 
180
  msgid "WordPress Comments"
181
  msgstr ""
182
 
183
- #: Includes/Integrations.php:267
184
  msgid ""
185
  "When activated the GDPR checkbox will be added automatically just above the "
186
  "submit button."
187
  msgstr ""
188
 
189
- #: Includes/Integrations.php:281
190
  msgid "Contact Form 7"
191
  msgstr ""
192
 
193
- #: Includes/Integrations.php:282 Includes/Integrations.php:289
194
  msgid "A GDPR form tag will be automatically added to every form you activate."
195
  msgstr ""
196
 
197
- #: Includes/Integrations.php:288
198
  msgid "Gravity Forms"
199
  msgstr ""
200
 
201
- #: Includes/Integrations.php:295
202
  msgid "WooCommerce"
203
  msgstr ""
204
 
205
- #: Includes/Integrations.php:296
206
  msgid ""
207
  "The GDPR checkbox will be added automatically at the end of your checkout "
208
  "page."
209
  msgstr ""
210
 
211
- #: Includes/Pages.php:53
212
- msgid "Integrations"
213
  msgstr ""
214
 
215
- #: Includes/Pages.php:54
 
 
 
 
216
  msgid "Checklist"
217
  msgstr ""
218
 
219
- #: Includes/Pages.php:55 wp-gdpr-compliance.php:97
220
  msgid "Settings"
221
  msgstr ""
222
 
223
- #: Includes/Pages.php:76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
224
  msgid "Enable:"
225
  msgstr ""
226
 
227
- #: Includes/Pages.php:105
228
  #, php-format
229
  msgid "This plugin is outdated. %s supports version %s and up."
230
  msgstr ""
231
 
232
- #: Includes/Pages.php:115
233
  msgid "Couldn't find any supported plugins installed."
234
  msgstr ""
235
 
236
- #: Includes/Pages.php:116
237
  msgid "The following plugins are supported as of now:"
238
  msgstr ""
239
 
240
- #: Includes/Pages.php:122
241
  msgid "More plugins will be added in the future."
242
  msgstr ""
243
 
244
- #: Includes/Pages.php:126
245
  msgid ""
246
  "Below we ask you what private data you currently collect and provide you "
247
  "with tips to comply."
248
  msgstr ""
249
 
250
- #: Includes/Pages.php:160
 
 
 
 
 
 
 
 
 
 
 
 
251
  msgid ""
252
- "Use %privacy_policy% if you want to link your Privacy Policy page in the "
253
- "GDPR checkbox texts."
 
 
254
  msgstr ""
255
 
256
- #: Includes/Pages.php:165
257
- msgid "Select an option"
258
  msgstr ""
259
 
260
- #: Includes/Pages.php:172
261
- msgid "Link text"
262
  msgstr ""
263
 
264
- #: Includes/Pages.php:183
265
- #, php-format
266
  msgid ""
267
- "This plugin assists website and webshop owners to comply with European "
268
- "privacy regulations known as GDPR. By May 24th, 2018 your site or shop has "
269
- "to comply to avoid large fines. The regulation can be read here: %s."
270
  msgstr ""
271
 
272
- #: Includes/Pages.php:183
273
- msgid "GDPR Key Changes"
274
  msgstr ""
275
 
276
- #: Includes/Pages.php:184
277
- #, php-format
278
- msgid "%s currently supports %s."
279
  msgstr ""
280
 
281
- #: Includes/Pages.php:187
 
 
 
 
282
  msgid ""
283
- "Disclaimer: The creators of this plugin do not have a legal background "
284
- "please contact a law firm for rock solid legal advice."
 
 
 
 
 
 
 
 
285
  msgstr ""
286
 
287
- #: Includes/Pages.php:193
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
  #, php-format
289
- msgid "You have %s left to comply with GDPR."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
290
  msgstr ""
291
 
292
- #: Includes/Pages.php:193
 
 
 
 
 
 
 
 
293
  #, php-format
294
- msgid "%s day"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
295
  msgstr ""
296
 
297
- #: wp-gdpr-compliance.php:97
298
  msgid "View WP GDPR Compliance settings"
299
  msgstr ""
1
+ #, fuzzy
2
  msgid ""
3
  msgstr ""
4
  "Project-Id-Version: WP GDPR Compliance\n"
5
+ "POT-Creation-Date: 2018-05-07 18:53+0200\n"
6
  "Last-Translator: \n"
7
  "Language-Team: Van Ons <info@van-ons.nl>\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
+ "PO-Revision-Date: \n"
12
+ "X-Generator: Poedit 2.0.6\n"
13
+ "X-Poedit-SourceCharset: UTF-8\n"
14
+ "X-Poedit-KeywordsList: __;_e;_ngettext:1,2;_n;_ngettext_noop:1,2;_n_noop:1,2;"
15
+ "_c;_nc:4c,1,2;_x:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;_ex:1,2c;esc_attr__;"
16
+ "esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n"
17
+ "X-Poedit-Basepath: ..\n"
18
+ "X-Poedit-SearchPath-0: .\n"
19
 
20
+ #: Includes/Action.php:37
21
+ msgid "Data Access Request"
22
+ msgstr ""
23
+
24
+ #: Includes/Ajax.php:27 Includes/Ajax.php:229
25
  msgid "Missing data."
26
  msgstr ""
27
 
37
  msgid "Missing value."
38
  msgstr ""
39
 
40
+ #: Includes/Ajax.php:80
41
+ msgid "Missing or incorrect email address."
42
+ msgstr ""
43
+
44
+ #: Includes/Ajax.php:84
45
+ msgid "You need to accept the privacy checkbox."
46
+ msgstr ""
47
+
48
+ #: Includes/Ajax.php:109
49
+ #, php-format
50
+ msgid "%s - Your data request"
51
+ msgstr ""
52
+
53
+ #: Includes/Ajax.php:111
54
+ #, php-format
55
+ msgid "You have requested to access your data on %s."
56
+ msgstr ""
57
+
58
+ #: Includes/Ajax.php:115
59
+ #, php-format
60
+ msgid "Please visit this %s to view the data linked to the email address %s"
61
+ msgstr ""
62
+
63
+ #: Includes/Ajax.php:127
64
+ msgid "page"
65
+ msgstr ""
66
+
67
+ #: Includes/Ajax.php:131
68
+ msgid ""
69
+ "This page is available for 24 hours and can only be reached from the same IP "
70
+ "address you requested from."
71
+ msgstr ""
72
+
73
+ #: Includes/Ajax.php:133
74
+ #, php-format
75
+ msgid "If your link is invalid please fill in a new request: %s."
76
+ msgstr ""
77
+
78
+ #: Includes/Ajax.php:142
79
+ msgid "Success. You will receive an email with your data shortly."
80
+ msgstr ""
81
+
82
+ #: Includes/Ajax.php:146
83
+ msgid "Something went wrong while saving the request."
84
+ msgstr ""
85
+
86
+ #: Includes/Ajax.php:149
87
+ msgid ""
88
+ "You have already requested your data. Please check your mailbox. After 24 "
89
+ "hours you can put in a new request."
90
+ msgstr ""
91
+
92
+ #: Includes/Ajax.php:162
93
+ msgid "Missing session."
94
+ msgstr ""
95
+
96
+ #: Includes/Ajax.php:166
97
+ msgid "Missing or invalid type."
98
+ msgstr ""
99
+
100
+ #: Includes/Ajax.php:170
101
+ msgid "No value selected."
102
+ msgstr ""
103
+
104
+ #: Includes/Ajax.php:191
105
+ msgid "Something went wrong while saving this request. Please try again."
106
+ msgstr ""
107
+
108
+ #: Includes/Ajax.php:194
109
+ msgid "Session doesn't match."
110
+ msgstr ""
111
+
112
+ #: Includes/Ajax.php:197
113
+ msgid "No session found."
114
+ msgstr ""
115
+
116
+ #: Includes/Ajax.php:219
117
+ msgid "The access request functionality is not enabled."
118
+ msgstr ""
119
+
120
+ #: Includes/Ajax.php:233
121
+ msgid "This delete request doesn't exist."
122
+ msgstr ""
123
+
124
+ #: Includes/Ajax.php:253
125
+ msgid "This user doesn't exist."
126
+ msgstr ""
127
+
128
+ #: Includes/Ajax.php:259
129
+ msgid "You're not allowed to edit users."
130
+ msgstr ""
131
+
132
+ #: Includes/Ajax.php:272
133
+ msgid "This comment doesn't exist."
134
+ msgstr ""
135
+
136
+ #: Includes/Ajax.php:278
137
+ msgid "You're not allowed to edit comments."
138
+ msgstr ""
139
+
140
+ #: Includes/Ajax.php:301
141
+ msgid "You're not allowed to edit WooCommerce orders."
142
+ msgstr ""
143
+
144
+ #: Includes/Ajax.php:306
145
+ msgid "This delete request has already been processed."
146
+ msgstr ""
147
+
148
+ #: Includes/Data.php:27 Includes/Extensions/WP.php:34 Includes/Shortcode.php:72
149
+ #, php-format
150
+ msgid "<strong>ERROR</strong>: %s"
151
+ msgstr ""
152
+
153
+ #: Includes/Data.php:28
154
+ msgid "Email Address is required."
155
+ msgstr ""
156
+
157
+ #: Includes/Data.php:52
158
+ msgid "Username"
159
+ msgstr ""
160
+
161
+ #: Includes/Data.php:53
162
+ msgid "Display Name"
163
+ msgstr ""
164
+
165
+ #: Includes/Data.php:54 Includes/Data.php:63 Includes/Data.php:70
166
+ #: Includes/Page.php:450
167
+ msgid "Email Address"
168
+ msgstr ""
169
+
170
+ #: Includes/Data.php:55
171
+ msgid "Website"
172
+ msgstr ""
173
+
174
+ #: Includes/Data.php:56
175
+ msgid "Registered on"
176
+ msgstr ""
177
+
178
+ #: Includes/Data.php:61
179
+ msgid "Author"
180
+ msgstr ""
181
+
182
+ #: Includes/Data.php:62
183
+ msgid "Content"
184
+ msgstr ""
185
+
186
+ #: Includes/Data.php:64 Includes/Page.php:366 Includes/Page.php:451
187
+ msgid "IP Address"
188
+ msgstr ""
189
+
190
+ #: Includes/Data.php:69
191
+ msgid "Order"
192
+ msgstr ""
193
+
194
+ #: Includes/Data.php:71
195
+ msgid "Name"
196
+ msgstr ""
197
+
198
+ #: Includes/Data.php:72
199
+ msgid "Address"
200
+ msgstr ""
201
+
202
+ #: Includes/Data.php:73
203
+ msgid "Postcode / ZIP"
204
+ msgstr ""
205
+
206
+ #: Includes/Data.php:74
207
+ msgid "City"
208
+ msgstr ""
209
+
210
  #: Includes/Extensions/CF7.php:184 Includes/Extensions/GForms.php:111
211
  #: Includes/Extensions/GForms.php:127 Includes/Extensions/GForms.php:146
212
+ #: Includes/Extensions/WC.php:55 Includes/Extensions/WP.php:69
213
  msgid "Not accepted."
214
  msgstr ""
215
 
226
  msgid "Accepted on %s."
227
  msgstr ""
228
 
229
+ #: Includes/Extensions/WP.php:24
230
+ msgid "required"
 
231
  msgstr ""
232
 
233
+ #: Includes/Extensions/WP.php:37
234
  msgid "Comment Submission Failure"
235
  msgstr ""
236
 
237
+ #: Includes/Extensions/WP.php:57
238
  msgid "GDPR Accepted On"
239
  msgstr ""
240
 
241
+ #: Includes/Helper.php:84
242
  #, php-format
243
  msgid "You can use: %s"
244
  msgstr ""
245
 
246
+ #: Includes/Helper.php:90 Includes/Helper.php:111 Includes/Page.php:287
247
  msgid "Note"
248
  msgstr ""
249
 
250
+ #: Includes/Helper.php:91
251
  msgid "No HTML allowed due to plugin limitations."
252
  msgstr ""
253
 
254
+ #: Includes/Helper.php:112
255
  msgid ""
256
  "Please disable the custom comments form in Jetpack to make your WordPress "
257
  "Comments GDPR compliant."
258
  msgstr ""
259
 
260
+ #: Includes/Helper.php:139
261
  msgid "Do you have a contact form?"
262
  msgstr ""
263
 
264
+ #: Includes/Helper.php:140
265
  msgid ""
266
  "Make sure you add a checkbox specifically asking the user of the form if "
267
  "they consent to you storing and using their personal information to get back "
269
  "if you will send or share the data with any 3rd-parties and which."
270
  msgstr ""
271
 
272
+ #: Includes/Helper.php:143
273
  msgid "Can visitors comment anywhere on your website?"
274
  msgstr ""
275
 
276
+ #: Includes/Helper.php:144
277
  msgid ""
278
  "Make sure you add a checkbox specifically asking the user of the comment "
279
  "section if they consent to storing their message attached to the e-mail "
282
  "which."
283
  msgstr ""
284
 
285
+ #: Includes/Helper.php:147
286
  msgid "Is there an order form on your website or webshop present?"
287
  msgstr ""
288
 
289
+ #: Includes/Helper.php:148
290
  msgid ""
291
  "Make sure you add a checkbox specifically asking the user of the form if "
292
  "they consent to you storing and using their personal information to ship the "
296
  "which."
297
  msgstr ""
298
 
299
+ #: Includes/Helper.php:151
300
  msgid "Do you provide a forum or message board?"
301
  msgstr ""
302
 
303
+ #: Includes/Helper.php:152
304
  msgid ""
305
  "Make sure you add a checkbox specifically asking forum / board users if they "
306
  "consent to you storing and using their personal information and messages. "
308
  "share the data with any 3rd-parties and which."
309
  msgstr ""
310
 
311
+ #: Includes/Helper.php:155
312
  msgid "Can visitors chat with your company directly?"
313
  msgstr ""
314
 
315
+ #: Includes/Helper.php:156
316
  msgid ""
317
  "Make sure you add a checkbox specifically asking chat users if they consent "
318
  "to you storing and using their personal information and messages. The "
321
  "mention if you will send or share the data with any 3rd-parties and which."
322
  msgstr ""
323
 
324
+ #: Includes/Integration.php:111 Includes/Integration.php:152
325
  #, php-format
326
  msgid "Form: %s"
327
  msgstr ""
328
 
329
+ #: Includes/Integration.php:112 Includes/Integration.php:153
330
  msgid "Activate for this form:"
331
  msgstr ""
332
 
333
+ #: Includes/Integration.php:115 Includes/Integration.php:156
334
+ #: Includes/Integration.php:183 Includes/Page.php:314
335
  msgid "Checkbox text"
336
  msgstr ""
337
 
338
+ #: Includes/Integration.php:121 Includes/Integration.php:162
339
+ #: Includes/Integration.php:189
340
  msgid "Error message"
341
  msgstr ""
342
 
343
+ #: Includes/Integration.php:131 Includes/Integration.php:172
344
  msgid "No forms found."
345
  msgstr ""
346
 
347
+ #: Includes/Integration.php:215 Includes/Integration.php:255
348
  msgid ""
349
  "By using this form you agree with the storage and handling of your data by "
350
  "this website."
351
  msgstr ""
352
 
353
+ #: Includes/Integration.php:232
354
  msgid "Please accept the privacy checkbox."
355
  msgstr ""
356
 
357
+ #: Includes/Integration.php:243 Includes/Page.php:253 Includes/Page.php:257
358
  msgid "Privacy Policy"
359
  msgstr ""
360
 
361
+ #: Includes/Integration.php:268
362
+ #, php-format
363
+ msgid ""
364
+ "Below we show you all of the data stored by %s on %s Select the data you "
365
+ "wish the site owner to anonymise so it cannot be linked to your email "
366
+ "address any longer. It is the site's owner responsibility to act upon your "
367
+ "request. When your data is anonymised you will receive an email confirmation."
368
+ msgstr ""
369
+
370
+ #: Includes/Integration.php:306 Includes/Page.php:354
371
  msgid "WordPress Comments"
372
  msgstr ""
373
 
374
+ #: Includes/Integration.php:307
375
  msgid ""
376
  "When activated the GDPR checkbox will be added automatically just above the "
377
  "submit button."
378
  msgstr ""
379
 
380
+ #: Includes/Integration.php:321
381
  msgid "Contact Form 7"
382
  msgstr ""
383
 
384
+ #: Includes/Integration.php:322 Includes/Integration.php:329
385
  msgid "A GDPR form tag will be automatically added to every form you activate."
386
  msgstr ""
387
 
388
+ #: Includes/Integration.php:328
389
  msgid "Gravity Forms"
390
  msgstr ""
391
 
392
+ #: Includes/Integration.php:335 Includes/Page.php:355
393
  msgid "WooCommerce"
394
  msgstr ""
395
 
396
+ #: Includes/Integration.php:336
397
  msgid ""
398
  "The GDPR checkbox will be added automatically at the end of your checkout "
399
  "page."
400
  msgstr ""
401
 
402
+ #: Includes/Page.php:53
403
+ msgid "Integration"
404
  msgstr ""
405
 
406
+ #: Includes/Page.php:59
407
+ msgid "Requests"
408
+ msgstr ""
409
+
410
+ #: Includes/Page.php:68
411
  msgid "Checklist"
412
  msgstr ""
413
 
414
+ #: Includes/Page.php:69 wp-gdpr-compliance.php:109
415
  msgid "Settings"
416
  msgstr ""
417
 
418
+ #: Includes/Page.php:97
419
+ msgid ""
420
+ "This plugin assists website and webshop owners to comply with European "
421
+ "privacy regulations known as GDPR. By May 25th, 2018 your site or shop has "
422
+ "to comply."
423
+ msgstr ""
424
+
425
+ #: Includes/Page.php:100
426
+ #, php-format
427
+ msgid ""
428
+ "%s currently supports %s. Please visit %s for frequently asked questions and "
429
+ "our development roadmap."
430
+ msgstr ""
431
+
432
+ #: Includes/Page.php:108
433
+ msgid ""
434
+ "Disclaimer: The creators of this plugin do not have a legal background "
435
+ "please contact a law firm for rock solid legal advice."
436
+ msgstr ""
437
+
438
+ #: Includes/Page.php:114
439
+ #, php-format
440
+ msgid "You have %s left to comply with GDPR."
441
+ msgstr ""
442
+
443
+ #: Includes/Page.php:114
444
+ #, php-format
445
+ msgid "%s day"
446
+ msgstr ""
447
+
448
+ #: Includes/Page.php:147
449
  msgid "Enable:"
450
  msgstr ""
451
 
452
+ #: Includes/Page.php:173
453
  #, php-format
454
  msgid "This plugin is outdated. %s supports version %s and up."
455
  msgstr ""
456
 
457
+ #: Includes/Page.php:182
458
  msgid "Couldn't find any supported plugins installed."
459
  msgstr ""
460
 
461
+ #: Includes/Page.php:183
462
  msgid "The following plugins are supported as of now:"
463
  msgstr ""
464
 
465
+ #: Includes/Page.php:189
466
  msgid "More plugins will be added in the future."
467
  msgstr ""
468
 
469
+ #: Includes/Page.php:201
470
  msgid ""
471
  "Below we ask you what private data you currently collect and provide you "
472
  "with tips to comply."
473
  msgstr ""
474
 
475
+ #: Includes/Page.php:262 Includes/Page.php:301
476
+ msgid "Select an option"
477
+ msgstr ""
478
+
479
+ #: Includes/Page.php:270
480
+ msgid "Link text"
481
+ msgstr ""
482
+
483
+ #: Includes/Page.php:275
484
+ msgid "Request User Data"
485
+ msgstr ""
486
+
487
+ #: Includes/Page.php:277
488
  msgid ""
489
+ "Allow your site's visitors to request their data stored in the WordPress "
490
+ "database (comments, WooCommerce orders etc.). Data found is send to their "
491
+ "email address and allows them to put in an additional request to have the "
492
+ "data anonymised."
493
  msgstr ""
494
 
495
+ #: Includes/Page.php:280
496
+ msgid "Activate"
497
  msgstr ""
498
 
499
+ #: Includes/Page.php:282
500
+ msgid "Activate page"
501
  msgstr ""
502
 
503
+ #: Includes/Page.php:288
 
504
  msgid ""
505
+ "Enabling this will create one private page containing the necessary "
506
+ "shortcode. You can determine when and how to publish this page yourself."
 
507
  msgstr ""
508
 
509
+ #: Includes/Page.php:296
510
+ msgid "Page"
511
  msgstr ""
512
 
513
+ #: Includes/Page.php:308
514
+ msgid "Click here to edit this page"
 
515
  msgstr ""
516
 
517
+ #: Includes/Page.php:320
518
+ msgid "Delete request explanation"
519
+ msgstr ""
520
+
521
+ #: Includes/Page.php:351
522
  msgid ""
523
+ "Anonymise a request by ticking the checkbox and clicking on the green "
524
+ "anonymise button below."
525
+ msgstr ""
526
+
527
+ #: Includes/Page.php:353
528
+ msgid "WordPress Users"
529
+ msgstr ""
530
+
531
+ #: Includes/Page.php:364
532
+ msgid "Request"
533
  msgstr ""
534
 
535
+ #: Includes/Page.php:365
536
+ msgid "Type"
537
+ msgstr ""
538
+
539
+ #: Includes/Page.php:367 Includes/Page.php:452
540
+ msgid "Date"
541
+ msgstr ""
542
+
543
+ #: Includes/Page.php:368
544
+ msgid "Processed"
545
+ msgstr ""
546
+
547
+ #: Includes/Page.php:369
548
+ msgid "Action"
549
+ msgstr ""
550
+
551
+ #: Includes/Page.php:384
552
+ msgid "View"
553
+ msgstr ""
554
+
555
+ #: Includes/Page.php:398
556
+ msgid "Anonymise selected request(s)"
557
+ msgstr ""
558
+
559
+ #: Includes/Page.php:420 Includes/Page.php:511
560
  #, php-format
561
+ msgid "%d of %d results found"
562
+ msgstr ""
563
+
564
+ #: Includes/Page.php:426
565
+ msgid "No delete requests found."
566
+ msgstr ""
567
+
568
+ #: Includes/Page.php:448
569
+ msgid "ID"
570
+ msgstr ""
571
+
572
+ #: Includes/Page.php:449
573
+ msgid "Requests to Process"
574
+ msgstr ""
575
+
576
+ #: Includes/Page.php:453
577
+ msgid "Expired"
578
+ msgstr ""
579
+
580
+ #: Includes/Page.php:477
581
+ msgid "Manage"
582
  msgstr ""
583
 
584
+ #: Includes/Page.php:517
585
+ msgid "No requests found."
586
+ msgstr ""
587
+
588
+ #: Includes/Shortcode.php:33
589
+ msgid "Users"
590
+ msgstr ""
591
+
592
+ #: Includes/Shortcode.php:40
593
  #, php-format
594
+ msgid "No users found with email address %s."
595
+ msgstr ""
596
+
597
+ #: Includes/Shortcode.php:45
598
+ msgid "Comments"
599
+ msgstr ""
600
+
601
+ #: Includes/Shortcode.php:52
602
+ #, php-format
603
+ msgid "No comments found with email address %s."
604
+ msgstr ""
605
+
606
+ #: Includes/Shortcode.php:57
607
+ msgid "WooCommerce Orders"
608
+ msgstr ""
609
+
610
+ #: Includes/Shortcode.php:64
611
+ #, php-format
612
+ msgid "No WooCommerce orders found with email address %s."
613
+ msgstr ""
614
+
615
+ #: Includes/Shortcode.php:73
616
+ msgid "What are you trying to do?"
617
+ msgstr ""
618
+
619
+ #: Includes/Shortcode.php:79
620
+ msgid "This request is expired or doesn't exist."
621
+ msgstr ""
622
+
623
+ #: Includes/Shortcode.php:99
624
+ msgid "Your Email Address"
625
+ msgstr ""
626
+
627
+ #: Includes/Shortcode.php:107
628
+ msgid "Send"
629
  msgstr ""
630
 
631
+ #: wp-gdpr-compliance.php:109
632
  msgid "View WP GDPR Compliance settings"
633
  msgstr ""
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: donnyoexman, michaelvt, jeffreyvisser, van-ons
3
  Tags: gdpr, law, regulations, compliance, data, protection, privacy, data protection, eu, avg, comments, woocommerce, wc, contact form 7, cf7
4
  Requires at least: 4.5
5
  Tested up to: 4.9.4
6
- Requires PHP: 5.2.4
7
- Stable tag: 1.2.4
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -12,7 +12,7 @@ This plugin assists website owners to comply with European privacy regulations (
12
 
13
  == Description ==
14
 
15
- ACTIVATION THIS PLUGIN DOES NOT GUARANTEE YOU FULLY COMPLY WITH GDPR. PLEASE CONTACT A GDPR CONSULTANT OR LAW FIRM TO ASSESS NECESSARY MEASURES.
16
 
17
  This plugin assists website and webshop owners to comply with European privacy regulations known as GDPR. By May 24th, 2018 your site or shop has to comply to avoid large fines.
18
 
@@ -32,11 +32,22 @@ You'll find answers to many of your questions on [wpgdprc.com](https://www.wpgdp
32
 
33
  == Screenshots ==
34
 
35
- 1. Automatically add GDPR checkboxes to some of your existing plugins, such as Contact Form 7, Gravity Forms, WooCommerce or WordPress Comments.
36
- 2. We provide you with tips based on the private data you currently collect in order to comply with the GDPR regulations.
 
37
 
38
  == Changelog ==
39
 
 
 
 
 
 
 
 
 
 
 
40
  = 1.2.4 =
41
  *Release date: April 3rd, 2018*
42
  * Show a notice when Jetpack is installed
3
  Tags: gdpr, law, regulations, compliance, data, protection, privacy, data protection, eu, avg, comments, woocommerce, wc, contact form 7, cf7
4
  Requires at least: 4.5
5
  Tested up to: 4.9.4
6
+ Requires PHP: 5.3
7
+ Stable tag: 1.3
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
12
 
13
  == Description ==
14
 
15
+ ACTIVATING THIS PLUGIN DOES NOT GUARANTEE YOU FULLY COMPLY WITH GDPR. PLEASE CONTACT A GDPR CONSULTANT OR LAW FIRM TO ASSESS NECESSARY MEASURES.
16
 
17
  This plugin assists website and webshop owners to comply with European privacy regulations known as GDPR. By May 24th, 2018 your site or shop has to comply to avoid large fines.
18
 
32
 
33
  == Screenshots ==
34
 
35
+ 1. Automatically add GDPR checkboxes to some of your favourite plugins.
36
+ 2. Overview of the view and delete requests by your site's visitors.
37
+ 3. Control the link to your privacy policy and activate the request user data page.
38
 
39
  == Changelog ==
40
 
41
+ = 1.3 =
42
+ *Release date: May 7th, 2018*
43
+ * Added the request user data page. You can enable it in the Settings tab.
44
+ * The newly created page contains a shortcode which allows visitors to request their data. WordPress Users, WordPress Comments and WooCommerce orders linked to their email address are then send to that email address.
45
+ * The request user data page becomes the delete user page when visited through this email. The link in the email is available for 24 hours (cronjob) and linked to the visitors' IP and current session.
46
+ * Delete requests end up in the new Requests tab. Click on 'Manage' to view a request and tick the checkbox to anonymise. Make sure to take care of these requests as quickly as possible!
47
+ * For WordPress Users 'anonymise' means first and last name, display name, nickname and email address are substituted by the corresponding field name in the database.
48
+ * For WordPress Comments 'anonymise' means author name, email address and IP address are substituted by the corresponding field name in the database.
49
+ * For WooCommerce orders 'anonymise' means billing and shipping details are substituted by the corresponding field name in the database.
50
+
51
  = 1.2.4 =
52
  *Release date: April 3rd, 2018*
53
  * Show a notice when Jetpack is installed
uninstall.php CHANGED
@@ -7,10 +7,27 @@ if (!defined('WP_UNINSTALL_PLUGIN')) {
7
 
8
  global $wpdb;
9
 
10
- // Remove everything related to the WP GDPR Compliance plugin
11
- $options = $wpdb->get_results("SELECT `option_name` FROM `" . $wpdb->options . "` WHERE `option_name` LIKE 'wpgdprc_%'");
12
- if ($options !== null) {
13
- foreach ($options as $option) {
14
- delete_option($option->option_name);
15
- }
16
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  global $wpdb;
9
 
10
+ // Pages
11
+ $accessRequest = get_pages(array(
12
+ 'post_type' => 'page',
13
+ 'post_status' => 'publish,private,draft',
14
+ 'number' => 1,
15
+ 'meta_key' => '_wpgdprc_access_request',
16
+ 'meta_value' => '1'
17
+ ));
18
+ if (!empty($accessRequest)) {
19
+ wp_trash_post($accessRequest[0]->ID);
20
+ }
21
+
22
+ // Options
23
+ $wpdb->query("DELETE FROM `$wpdb->options` WHERE `option_name` LIKE 'wpgdprc\_%';");
24
+
25
+ // Tables
26
+ $wpdb->query("DROP TABLE IF EXISTS `{$wpdb->base_prefix}wpgdprc_access_requests`");
27
+ $wpdb->query("DROP TABLE IF EXISTS `{$wpdb->base_prefix}wpgdprc_delete_requests`");
28
+
29
+ // Cronjobs
30
+ wp_clear_scheduled_hook('wpgdprc_deactivate_access_requests');
31
+
32
+ // Clear any cached data that has been removed
33
+ wp_cache_flush();
wp-gdpr-compliance.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: WP GDPR Compliance
5
  Plugin URI: https://www.wpgdprc.com/
6
  Description: This plugin assists website and webshop owners to comply with European privacy regulations known as GDPR. By May 24th, 2018 your website or shop has to comply to avoid large fines.
7
- Version: 1.2.4
8
  Author: Van Ons
9
  Author URI: https://www.van-ons.nl/
10
  License: GPL2
@@ -30,16 +30,22 @@ along with this program. If not, see http://www.gnu.org/licenses.
30
 
31
  namespace WPGDPRC;
32
 
33
- use WPGDPRC\Includes\Actions;
34
  use WPGDPRC\Includes\Ajax;
35
- use WPGDPRC\Includes\Integrations;
36
- use WPGDPRC\Includes\Pages;
 
 
 
 
 
37
 
38
  // If this file is called directly, abort.
39
  if (!defined('WPINC')) {
40
  die();
41
  }
42
 
 
43
  define('WP_GDPR_C_SLUG', 'wp-gdpr-compliance');
44
  define('WP_GDPR_C_PREFIX', 'wpgdprc');
45
  define('WP_GDPR_C_ROOT_FILE', __FILE__);
@@ -64,28 +70,34 @@ class WPGDPRC {
64
  /** @var null */
65
  private static $instance = null;
66
 
67
- /**
68
- * @return null|WPGDPRC
69
- */
70
- public static function getInstance() {
71
- if (!isset(self::$instance)) {
72
- self::$instance = new self();
73
- }
74
- return self::$instance;
75
- }
76
-
77
  public function init() {
78
  if (is_admin() && !function_exists('get_plugin_data')) {
79
  require_once(ABSPATH . 'wp-admin/includes/plugin.php');
80
  }
81
  load_plugin_textdomain(WP_GDPR_C_SLUG, false, basename(dirname(__FILE__)) . '/languages/');
82
  add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'addActionLinksToPluginPage'));
83
- add_action('admin_init', array(Pages::getInstance(), 'registerSettings'));
84
- add_action('admin_menu', array(Pages::getInstance(), 'addAdminMenu'));
85
- add_action('admin_enqueue_scripts', array($this, 'loadAssets'), 999);
86
- add_action('core_version_check_query_args', array(Actions::getInstance(), 'onlySendEssentialDataDuringUpdateCheck'));
 
 
87
  add_action('wp_ajax_wpgdprc_process_action', array(Ajax::getInstance(), 'processAction'));
88
- Integrations::getInstance();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  }
90
 
91
  /**
@@ -94,19 +106,42 @@ class WPGDPRC {
94
  */
95
  public function addActionLinksToPluginPage($links = array()) {
96
  $actionLinks = array(
97
- 'settings' => '<a href="' . admin_url('tools.php?page=' . str_replace('-', '_', WP_GDPR_C_SLUG)) . '" aria-label="' . esc_attr__('View WP GDPR Compliance settings', WP_GDPR_C_SLUG) . '">' . esc_html__('Settings', WP_GDPR_C_SLUG) . '</a>',
98
  );
99
  return array_merge($actionLinks, $links);
100
  }
101
 
102
  public function loadAssets() {
103
- wp_enqueue_style('wpgdprc.css', WP_GDPR_C_URI_CSS . '/admin.css', array(), filemtime(WP_GDPR_C_DIR_CSS . '/admin.css'));
104
- wp_enqueue_script('wpgdprc.js', WP_GDPR_C_URI_JS . '/admin.js', array(), filemtime(WP_GDPR_C_DIR_JS . '/admin.js'), true);
105
- wp_localize_script('wpgdprc.js', 'wpgdprcData', array(
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  'ajaxURL' => admin_url('admin-ajax.php'),
107
  'ajaxSecurity' => wp_create_nonce('wpgdprc'),
108
  ));
109
  }
 
 
 
 
 
 
 
 
 
 
110
  }
111
 
112
  /**
4
  Plugin Name: WP GDPR Compliance
5
  Plugin URI: https://www.wpgdprc.com/
6
  Description: This plugin assists website and webshop owners to comply with European privacy regulations known as GDPR. By May 24th, 2018 your website or shop has to comply to avoid large fines.
7
+ Version: 1.3
8
  Author: Van Ons
9
  Author URI: https://www.van-ons.nl/
10
  License: GPL2
30
 
31
  namespace WPGDPRC;
32
 
33
+ use WPGDPRC\Includes\Action;
34
  use WPGDPRC\Includes\Ajax;
35
+ use WPGDPRC\Includes\Cron;
36
+ use WPGDPRC\Includes\Filter;
37
+ use WPGDPRC\Includes\Helper;
38
+ use WPGDPRC\Includes\Integration;
39
+ use WPGDPRC\Includes\Page;
40
+ use WPGDPRC\Includes\AccessRequest;
41
+ use WPGDPRC\Includes\Shortcode;
42
 
43
  // If this file is called directly, abort.
44
  if (!defined('WPINC')) {
45
  die();
46
  }
47
 
48
+ define('WP_GDPR_C_VERSION', '1.2.4');
49
  define('WP_GDPR_C_SLUG', 'wp-gdpr-compliance');
50
  define('WP_GDPR_C_PREFIX', 'wpgdprc');
51
  define('WP_GDPR_C_ROOT_FILE', __FILE__);
70
  /** @var null */
71
  private static $instance = null;
72
 
 
 
 
 
 
 
 
 
 
 
73
  public function init() {
74
  if (is_admin() && !function_exists('get_plugin_data')) {
75
  require_once(ABSPATH . 'wp-admin/includes/plugin.php');
76
  }
77
  load_plugin_textdomain(WP_GDPR_C_SLUG, false, basename(dirname(__FILE__)) . '/languages/');
78
  add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'addActionLinksToPluginPage'));
79
+ add_action('admin_init', array(Page::getInstance(), 'registerSettings'));
80
+ add_action('admin_menu', array(Page::getInstance(), 'addAdminMenu'));
81
+ add_action('wp_enqueue_scripts', array($this, 'loadAssets'), 999);
82
+ add_action('admin_enqueue_scripts', array($this, 'loadAdminAssets'), 999);
83
+ add_action('core_version_check_query_args', array(Action::getInstance(), 'onlySendEssentialDataDuringUpdateCheck'));
84
+ add_action('wp_ajax_nopriv_wpgdprc_process_action', array(Ajax::getInstance(), 'processAction'));
85
  add_action('wp_ajax_wpgdprc_process_action', array(Ajax::getInstance(), 'processAction'));
86
+ add_action('update_option_wpgdprc_settings_enable_access_request', array(Action::getInstance(), 'processEnableAccessRequest'));
87
+ add_filter('pre_update_option_wpgdprc_settings_access_request_page', array(Filter::getInstance(), 'processEnableAccessRequest'));
88
+ Integration::getInstance();
89
+ if (Helper::isEnabled('enable_access_request', 'settings')) {
90
+ add_action('wpgdprc_deactivate_access_requests', array(Cron::getInstance(), 'deactivateAccessRequests'));
91
+ add_action('wp_ajax_wpgdprc_process_delete_request', array(Ajax::getInstance(), 'processDeleteRequest'));
92
+ add_shortcode('wpgdprc_access_request_form', array(Shortcode::getInstance(), 'accessRequestForm'));
93
+ if (!wp_next_scheduled('wpgdprc_deactivate_access_requests')) {
94
+ wp_schedule_event(time(), 'hourly', 'wpgdprc_deactivate_access_requests');
95
+ }
96
+ } else {
97
+ if (wp_next_scheduled('wpgdprc_deactivate_access_requests')) {
98
+ wp_clear_scheduled_hook('wpgdprc_deactivate_access_requests');
99
+ }
100
+ }
101
  }
102
 
103
  /**
106
  */
107
  public function addActionLinksToPluginPage($links = array()) {
108
  $actionLinks = array(
109
+ 'settings' => '<a href="' . add_query_arg(array('page' => str_replace('-', '_', WP_GDPR_C_SLUG)), admin_url('tools.php')) . '" aria-label="' . esc_attr__('View WP GDPR Compliance settings', WP_GDPR_C_SLUG) . '">' . esc_html__('Settings', WP_GDPR_C_SLUG) . '</a>',
110
  );
111
  return array_merge($actionLinks, $links);
112
  }
113
 
114
  public function loadAssets() {
115
+ wp_register_style('wpgdprc.css', WP_GDPR_C_URI_CSS . '/front.css', array(), filemtime(WP_GDPR_C_DIR_CSS . '/front.css'));
116
+ wp_register_script('wpgdprc.js', WP_GDPR_C_URI_JS . '/front.js', array(), filemtime(WP_GDPR_C_DIR_JS . '/front.js'), true);
117
+ $data = array(
118
+ 'ajaxURL' => admin_url('admin-ajax.php'),
119
+ 'ajaxSecurity' => wp_create_nonce('wpgdprc'),
120
+ );
121
+ if (!empty($_REQUEST['wpgdprc'])) {
122
+ $data['session'] = esc_html($_REQUEST['wpgdprc']);
123
+ }
124
+ wp_localize_script('wpgdprc.js', 'wpgdprcData', $data);
125
+ }
126
+
127
+ public function loadAdminAssets() {
128
+ wp_enqueue_style('wpgdprc.admin.css', WP_GDPR_C_URI_CSS . '/admin.css', array(), filemtime(WP_GDPR_C_DIR_CSS . '/admin.css'));
129
+ wp_enqueue_script('wpgdprc.admin.js', WP_GDPR_C_URI_JS . '/admin.js', array(), filemtime(WP_GDPR_C_DIR_JS . '/admin.js'), true);
130
+ wp_localize_script('wpgdprc.admin.js', 'wpgdprcData', array(
131
  'ajaxURL' => admin_url('admin-ajax.php'),
132
  'ajaxSecurity' => wp_create_nonce('wpgdprc'),
133
  ));
134
  }
135
+
136
+ /**
137
+ * @return null|WPGDPRC
138
+ */
139
+ public static function getInstance() {
140
+ if (!isset(self::$instance)) {
141
+ self::$instance = new self();
142
+ }
143
+ return self::$instance;
144
+ }
145
  }
146
 
147
  /**