Version Description
Release date: December 17th, 2018 * Bugfix older PHP versions.
Download this release
Release Info
Developer | donnyoexman |
Plugin | WP GDPR Compliance |
Version | 1.4.7 |
Comparing to | |
See all releases |
Code changes from version 1.4.6 to 1.4.7
- Includes/Integration.php +22 -21
- readme.txt +12 -7
- wp-gdpr-compliance.php +187 -184
Includes/Integration.php
CHANGED
@@ -24,11 +24,11 @@ class Integration {
|
|
24 |
foreach (Helper::getEnabledPlugins() as $plugin) {
|
25 |
switch ($plugin['id']) {
|
26 |
case WP::ID :
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
add_action('pre_comment_on_post', array(WP::getInstance(), 'checkPost'));
|
33 |
add_action('comment_post', array(WP::getInstance(), 'addAcceptedDateToCommentMeta'));
|
34 |
add_filter('manage_edit-comments_columns', array(WP::getInstance(), 'displayAcceptedDateColumnInCommentOverview'));
|
@@ -42,13 +42,14 @@ class Integration {
|
|
42 |
add_filter('wpcf7_before_send_mail', array(CF7::getInstance(), 'changeMailBodyOutput'), 999);
|
43 |
add_filter('wpcf7_validate_wpgdprc', array(CF7::getInstance(), 'validateField'), 10, 2);
|
44 |
break;
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
52 |
case WC::ID :
|
53 |
add_action('woocommerce_checkout_process', array(WC::getInstance(), 'checkPostCheckoutForm'));
|
54 |
add_action('woocommerce_register_post', array(WC::getInstance(), 'checkPostRegisterForm'), 10, 3);
|
@@ -269,7 +270,7 @@ class Integration {
|
|
269 |
return apply_filters('wpgdprc_error_message', wp_kses($output, Helper::getAllowedHTMLTags($plugin)));
|
270 |
}
|
271 |
|
272 |
-
|
273 |
* @param string $plugin
|
274 |
* @return mixed
|
275 |
*/
|
@@ -340,9 +341,9 @@ class Integration {
|
|
340 |
*/
|
341 |
public static function insertPrivacyPolicyLink($content = '') {
|
342 |
if (!Helper::isEnabled('enable_privacy_policy_extern', 'settings')) {
|
343 |
-
|
344 |
} else {
|
345 |
-
|
346 |
}
|
347 |
$text = Integration::getPrivacyPolicyText();
|
348 |
if ((!empty($page) || !empty($url)) && !empty($text)) {
|
@@ -350,7 +351,7 @@ class Integration {
|
|
350 |
'wpgdprc_privacy_policy_link',
|
351 |
sprintf(
|
352 |
'<a target="_blank" href="%s" rel="noopener noreferrer">%s</a>',
|
353 |
-
|
354 |
esc_html($text)
|
355 |
),
|
356 |
(Helper::isEnabled('enable_privacy_policy_extern', 'settings')) ? $url : $page,
|
@@ -371,11 +372,11 @@ class Integration {
|
|
371 |
'name' => __('WordPress Comments', WP_GDPR_C_SLUG),
|
372 |
'description' => __('When activated the GDPR checkbox will be added automatically just above the submit button.', WP_GDPR_C_SLUG),
|
373 |
),
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
);
|
380 |
}
|
381 |
|
24 |
foreach (Helper::getEnabledPlugins() as $plugin) {
|
25 |
switch ($plugin['id']) {
|
26 |
case WP::ID :
|
27 |
+
if (current_user_can('administrator')) {
|
28 |
+
add_filter('comment_form_submit_field', array(WP::getInstance(), 'addFieldForAdmin'), 999);
|
29 |
+
} else {
|
30 |
+
add_filter('comment_form_submit_field', array(WP::getInstance(), 'addField'), 999);
|
31 |
+
}
|
32 |
add_action('pre_comment_on_post', array(WP::getInstance(), 'checkPost'));
|
33 |
add_action('comment_post', array(WP::getInstance(), 'addAcceptedDateToCommentMeta'));
|
34 |
add_filter('manage_edit-comments_columns', array(WP::getInstance(), 'displayAcceptedDateColumnInCommentOverview'));
|
42 |
add_filter('wpcf7_before_send_mail', array(CF7::getInstance(), 'changeMailBodyOutput'), 999);
|
43 |
add_filter('wpcf7_validate_wpgdprc', array(CF7::getInstance(), 'validateField'), 10, 2);
|
44 |
break;
|
45 |
+
case WPRegistration::ID :
|
46 |
+
$users_can_register = get_option('users_can_register');
|
47 |
+
if ($users_can_register) {
|
48 |
+
add_action('register_form', array(WPRegistration::getInstance(), 'addField'), 999);
|
49 |
+
add_filter('registration_errors', array(WPRegistration::getInstance(), 'validateGDPRCheckbox'), 10, 3);
|
50 |
+
add_action('user_register', array(WPRegistration::getInstance(), 'logGivenGDPRConsent'), 10, 1);
|
51 |
+
}
|
52 |
+
break;
|
53 |
case WC::ID :
|
54 |
add_action('woocommerce_checkout_process', array(WC::getInstance(), 'checkPostCheckoutForm'));
|
55 |
add_action('woocommerce_register_post', array(WC::getInstance(), 'checkPostRegisterForm'), 10, 3);
|
270 |
return apply_filters('wpgdprc_error_message', wp_kses($output, Helper::getAllowedHTMLTags($plugin)));
|
271 |
}
|
272 |
|
273 |
+
/**
|
274 |
* @param string $plugin
|
275 |
* @return mixed
|
276 |
*/
|
341 |
*/
|
342 |
public static function insertPrivacyPolicyLink($content = '') {
|
343 |
if (!Helper::isEnabled('enable_privacy_policy_extern', 'settings')) {
|
344 |
+
$page = get_option(WP_GDPR_C_PREFIX . '_settings_privacy_policy_page');
|
345 |
} else {
|
346 |
+
$url = get_option(WP_GDPR_C_PREFIX . '_settings_privacy_policy_link');
|
347 |
}
|
348 |
$text = Integration::getPrivacyPolicyText();
|
349 |
if ((!empty($page) || !empty($url)) && !empty($text)) {
|
351 |
'wpgdprc_privacy_policy_link',
|
352 |
sprintf(
|
353 |
'<a target="_blank" href="%s" rel="noopener noreferrer">%s</a>',
|
354 |
+
(Helper::isEnabled('enable_privacy_policy_extern', 'settings')) ? $url : get_page_link($page),
|
355 |
esc_html($text)
|
356 |
),
|
357 |
(Helper::isEnabled('enable_privacy_policy_extern', 'settings')) ? $url : $page,
|
372 |
'name' => __('WordPress Comments', WP_GDPR_C_SLUG),
|
373 |
'description' => __('When activated the GDPR checkbox will be added automatically just above the submit button.', WP_GDPR_C_SLUG),
|
374 |
),
|
375 |
+
array(
|
376 |
+
'id' => WPRegistration::ID,
|
377 |
+
'name' => __('Wordpress Registration', WP_GDPR_C_SLUG),
|
378 |
+
'description' => __('When activated the GDPR checkbox will be added automatically just above the register button.', WP_GDPR_C_SLUG),
|
379 |
+
)
|
380 |
);
|
381 |
}
|
382 |
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: gdpr, law, regulations, compliance, data, protection, privacy, data protec
|
|
4 |
Requires at least: 4.5
|
5 |
Tested up to: 4.9.4
|
6 |
Requires PHP: 5.3
|
7 |
-
Stable tag: 1.4.
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -45,13 +45,18 @@ You'll find answers to many of your questions on [https://www.wpgdprc.com/faq/](
|
|
45 |
|
46 |
== Changelog ==
|
47 |
|
|
|
|
|
|
|
|
|
48 |
= 1.4.6 =
|
49 |
-
*
|
50 |
-
*Added
|
51 |
-
*Added
|
52 |
-
*Added
|
53 |
-
*
|
54 |
-
*Fixed bug
|
|
|
55 |
|
56 |
= 1.4.5 =
|
57 |
*Release date: November 30th, 2018*
|
4 |
Requires at least: 4.5
|
5 |
Tested up to: 4.9.4
|
6 |
Requires PHP: 5.3
|
7 |
+
Stable tag: 1.4.7
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
45 |
|
46 |
== Changelog ==
|
47 |
|
48 |
+
= 1.4.7 =
|
49 |
+
*Release date: December 17th, 2018*
|
50 |
+
* Bugfix older PHP versions.
|
51 |
+
|
52 |
= 1.4.6 =
|
53 |
+
*Release date: December 17th, 2018*
|
54 |
+
* Added anonymised usernames.
|
55 |
+
* Added log table.
|
56 |
+
* Added integration for WordPress registration.
|
57 |
+
* Added warning in case the privacy policy page has not been selected yet.
|
58 |
+
* Fixed bug in the settings page.
|
59 |
+
* Fixed bug with session ID’s.
|
60 |
|
61 |
= 1.4.5 =
|
62 |
*Release date: November 30th, 2018*
|
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.4.
|
8 |
Author: Van Ons
|
9 |
Author URI: https://www.van-ons.nl/
|
10 |
License: GPL2
|
@@ -68,7 +68,7 @@ define('WP_GDPR_C_URI_SVG', WP_GDPR_C_URI_ASSETS . '/svg');
|
|
68 |
spl_autoload_register(__NAMESPACE__ . '\\autoload');
|
69 |
add_action('plugins_loaded', array(WPGDPRC::getInstance(), 'init'));
|
70 |
add_action('wp', array(WPGDPRC::getInstance(), 'checkSession'));
|
71 |
-
add_action('save_post', array(WPGDPRC::getInstance(), 'checkIfAccessRequestPage'), 10, 3
|
72 |
|
73 |
register_activation_hook(__FILE__, array(Action::getInstance(), 'addTagsToFields'));
|
74 |
register_deactivation_hook(__FILE__, array(Action::getInstance(), 'removeTagsFromFields'));
|
@@ -78,171 +78,174 @@ register_deactivation_hook(__FILE__, array(Action::getInstance(), 'removeTagsFro
|
|
78 |
* @package WPGDPRC
|
79 |
*/
|
80 |
class WPGDPRC {
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
|
|
|
|
|
|
227 |
|
228 |
public static function addConsentVersion() {
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
}
|
233 |
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
|
247 |
public static function handleDatabaseTables() {
|
248 |
$dbVersion = get_option('wpgdprc_db_version', 0);
|
@@ -290,23 +293,23 @@ class WPGDPRC {
|
|
290 |
}
|
291 |
|
292 |
// Add column 'token' to 'Access Requests' table
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
ADD column `token` text NOT NULL AFTER `ip_address`;";
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
ID BIGINT NOT NULL AUTO_INCREMENT,
|
311 |
plugin_id VARCHAR(255) NULL,
|
312 |
form_id VARCHAR(255) NULL,
|
@@ -318,11 +321,11 @@ class WPGDPRC {
|
|
318 |
PRIMARY KEY (ID))
|
319 |
CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci';
|
320 |
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
}
|
327 |
|
328 |
/**
|
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.4.7
|
8 |
Author: Van Ons
|
9 |
Author URI: https://www.van-ons.nl/
|
10 |
License: GPL2
|
68 |
spl_autoload_register(__NAMESPACE__ . '\\autoload');
|
69 |
add_action('plugins_loaded', array(WPGDPRC::getInstance(), 'init'));
|
70 |
add_action('wp', array(WPGDPRC::getInstance(), 'checkSession'));
|
71 |
+
add_action('save_post', array(WPGDPRC::getInstance(), 'checkIfAccessRequestPage'), 10, 3);
|
72 |
|
73 |
register_activation_hook(__FILE__, array(Action::getInstance(), 'addTagsToFields'));
|
74 |
register_deactivation_hook(__FILE__, array(Action::getInstance(), 'removeTagsFromFields'));
|
78 |
* @package WPGDPRC
|
79 |
*/
|
80 |
class WPGDPRC {
|
81 |
+
/** @var null */
|
82 |
+
private static $instance = null;
|
83 |
+
|
84 |
+
public function init() {
|
85 |
+
self::handleDatabaseTables();
|
86 |
+
self::addConsentVersion();
|
87 |
+
self::removeOldConsentCookies();
|
88 |
+
if (is_admin()) {
|
89 |
+
Action::getInstance()->handleRedirects();
|
90 |
+
if (!function_exists('get_plugin_data')) {
|
91 |
+
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
92 |
+
}
|
93 |
+
}
|
94 |
+
$action = (isset($_REQUEST['wpgdprc-action'])) ? esc_html($_REQUEST['wpgdprc-action']) : false;
|
95 |
+
Helper::doAction($action);
|
96 |
+
load_plugin_textdomain(WP_GDPR_C_SLUG, false, basename(dirname(__FILE__)) . '/languages/');
|
97 |
+
add_filter('plugin_action_links_' . plugin_basename(__FILE__), array(
|
98 |
+
$this,
|
99 |
+
'addActionLinksToPluginPage'
|
100 |
+
));
|
101 |
+
add_action('admin_init', array(Page::getInstance(), 'registerSettings'));
|
102 |
+
add_action('admin_menu', array(Page::getInstance(), 'addAdminMenu'));
|
103 |
+
add_action('admin_notices', array(Action::getInstance(), 'showAdminNotices'));
|
104 |
+
add_action('wp_enqueue_scripts', array($this, 'loadAssets'), 999);
|
105 |
+
add_action('admin_enqueue_scripts', array($this, 'loadAdminAssets'), 999);
|
106 |
+
add_action('core_version_check_query_args', array(
|
107 |
+
Action::getInstance(),
|
108 |
+
'onlySendEssentialDataDuringUpdateCheck'
|
109 |
+
));
|
110 |
+
add_filter('cron_schedules', array(Cron::getInstance(), 'addCronSchedules'));
|
111 |
+
add_action('wp_ajax_wpgdprc_process_settings', array(Ajax::getInstance(), 'processSettings'));
|
112 |
+
add_action('wp_ajax_wpgdprc_process_action', array(Ajax::getInstance(), 'processAction'));
|
113 |
+
add_action('wp_ajax_nopriv_wpgdprc_process_action', array(Ajax::getInstance(), 'processAction'));
|
114 |
+
add_action('update_option_wpgdprc_settings_enable_access_request', array(
|
115 |
+
Action::getInstance(),
|
116 |
+
'processToggleAccessRequest'
|
117 |
+
));
|
118 |
+
Integration::getInstance();
|
119 |
+
if (Helper::isEnabled('enable_access_request', 'settings')) {
|
120 |
+
add_action('init', array(Action::getInstance(), 'processEnableAccessRequest'));
|
121 |
+
add_action('admin_notices', array(Action::getInstance(), 'showNoticesRequestUserData'));
|
122 |
+
add_action('wpgdprc_deactivate_access_requests', array(
|
123 |
+
Cron::getInstance(),
|
124 |
+
'deactivateAccessRequests'
|
125 |
+
));
|
126 |
+
add_action('wpgdprc_anonymise_requests', array(Cron::getInstance(), 'anonymiseRequests'));
|
127 |
+
add_action('wp_ajax_wpgdprc_process_delete_request', array(
|
128 |
+
Ajax::getInstance(),
|
129 |
+
'processDeleteRequest'
|
130 |
+
));
|
131 |
+
add_shortcode('wpgdprc_access_request_form', array(Shortcode::getInstance(), 'accessRequestForm'));
|
132 |
+
if (!wp_next_scheduled('wpgdprc_deactivate_access_requests')) {
|
133 |
+
wp_schedule_event(time(), 'hourly', 'wpgdprc_deactivate_access_requests');
|
134 |
+
}
|
135 |
+
if (!wp_next_scheduled('wpgdprc_anonymise_requests')) {
|
136 |
+
wp_schedule_event(time(), 'wpgdprc-monthly', 'wpgdprc_anonymise_requests');
|
137 |
+
}
|
138 |
+
} else {
|
139 |
+
if (wp_next_scheduled('wpgdprc_deactivate_access_requests')) {
|
140 |
+
wp_clear_scheduled_hook('wpgdprc_deactivate_access_requests');
|
141 |
+
}
|
142 |
+
if (wp_next_scheduled('wpgdprc_anonymise_requests')) {
|
143 |
+
wp_clear_scheduled_hook('wpgdprc_anonymise_requests');
|
144 |
+
}
|
145 |
+
}
|
146 |
+
if (Consent::databaseTableExists()) {
|
147 |
+
add_shortcode('wpgdprc_consents_settings_link', array(
|
148 |
+
Shortcode::getInstance(),
|
149 |
+
'consentsSettingsLink'
|
150 |
+
));
|
151 |
+
if (Consent::getInstance()->getTotal(array('active' => array('value' => 1))) > 0) {
|
152 |
+
add_action('wp_footer', array(Action::getInstance(), 'addConsentBar'), 998);
|
153 |
+
add_action('wp_footer', array(Action::getInstance(), 'addConsentModal'), 999);
|
154 |
+
add_action('wp_head', array(Action::getInstance(), 'addConsentsToHead'), 999);
|
155 |
+
add_action('wp_footer', array(Action::getInstance(), 'addConsentsToFooter'), 999);
|
156 |
+
}
|
157 |
+
}
|
158 |
+
add_filter('wpgdprc_the_content', 'wptexturize');
|
159 |
+
add_filter('wpgdprc_the_content', 'convert_smilies', 20);
|
160 |
+
add_filter('wpgdprc_the_content', 'wpautop');
|
161 |
+
add_filter('wpgdprc_the_content', 'shortcode_unautop');
|
162 |
+
add_filter('wpgdprc_the_content', 'wp_make_content_images_responsive');
|
163 |
+
}
|
164 |
+
|
165 |
+
public static function checkSession() {
|
166 |
+
global $post;
|
167 |
+
|
168 |
+
$status = get_option('wpgdprc_data_access_request_status');
|
169 |
+
|
170 |
+
if ($status !== 'done') {
|
171 |
+
$ids = get_option('wpgdprc_data_access_request_ids');
|
172 |
+
|
173 |
+
if (empty($ids)) {
|
174 |
+
$postIdsToSave = array();
|
175 |
+
|
176 |
+
// WP_Query arguments
|
177 |
+
$args = array(
|
178 |
+
'post_status' => array('publish'),
|
179 |
+
's' => '[wpgdprc_access_request_form]',
|
180 |
+
);
|
181 |
+
|
182 |
+
// The Query
|
183 |
+
$query = new WP_Query($args);
|
184 |
+
|
185 |
+
if ($query->have_posts()) {
|
186 |
+
while ($query->have_posts()) {
|
187 |
+
$query->the_post();
|
188 |
+
|
189 |
+
$shortcode = has_shortcode(get_the_content(), 'wpgdprc_access_request_form');
|
190 |
+
if ($shortcode) {
|
191 |
+
array_push($postIdsToSave, intval(get_the_ID()));
|
192 |
+
}
|
193 |
+
}
|
194 |
+
wp_reset_postdata();
|
195 |
+
}
|
196 |
+
update_option('wpgdprc_data_access_request_ids', $postIdsToSave);
|
197 |
+
}
|
198 |
+
}
|
199 |
+
|
200 |
+
$ids = get_option('wpgdprc_data_access_request_ids');
|
201 |
+
if (!is_array($ids)) {
|
202 |
+
$ids = array();
|
203 |
+
}
|
204 |
+
if (in_array($post->ID, $ids)) {
|
205 |
+
SessionHelper::startSession();
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
public static function checkIfAccessRequestPage($postId, $post, $update) {
|
210 |
+
$ids = get_option('wpgdprc_data_access_request_ids');
|
211 |
+
if (!is_array($ids)) {
|
212 |
+
$ids = array();
|
213 |
+
}
|
214 |
+
if (!in_array($postId, $ids)) {
|
215 |
+
if (has_shortcode($post->post_content, 'wpgdprc_access_request_form')) {
|
216 |
+
array_push($ids, $postId);
|
217 |
+
update_option('wpgdprc_data_access_request_ids', $ids);
|
218 |
+
} else {
|
219 |
+
if (in_array($postId, $ids)) {
|
220 |
+
foreach ($ids as $id => $value) {
|
221 |
+
if ($value === $postId) {
|
222 |
+
unset($ids[$id]);
|
223 |
+
}
|
224 |
+
}
|
225 |
+
update_option('wpgdprc_data_access_request_ids', $ids);
|
226 |
+
}
|
227 |
+
}
|
228 |
+
}
|
229 |
+
}
|
230 |
|
231 |
public static function addConsentVersion() {
|
232 |
+
if (!get_option('wpgdprc_consent_version')) {
|
233 |
+
update_option('wpgdprc_consent_version', '1');
|
234 |
+
}
|
235 |
}
|
236 |
|
237 |
+
public static function removeOldConsentCookies() {
|
238 |
+
$consentVersion = get_option('wpgdprc_consent_version');
|
239 |
+
foreach ($_COOKIE as $cookie => $val) {
|
240 |
+
if (strpos($cookie, 'wpgdprc-consent-') !== false) {
|
241 |
+
preg_match_all('!\d+!', $cookie, $matches);
|
242 |
+
if (intval($matches[0][0]) < intval($consentVersion)) {
|
243 |
+
unset($_COOKIE[$cookie]);
|
244 |
+
setcookie($cookie, null, -1, '/');
|
245 |
+
}
|
246 |
+
}
|
247 |
+
}
|
248 |
+
}
|
249 |
|
250 |
public static function handleDatabaseTables() {
|
251 |
$dbVersion = get_option('wpgdprc_db_version', 0);
|
293 |
}
|
294 |
|
295 |
// Add column 'token' to 'Access Requests' table
|
296 |
+
if (version_compare($dbVersion, '1.5', '<')) {
|
297 |
+
if ($wpdb->get_var("SHOW TABLES LIKE '" . AccessRequest::getDatabaseTableName() . "'") === AccessRequest::getDatabaseTableName()) {
|
298 |
+
if (!$wpdb->get_var("SHOW COLUMNS FROM " . AccessRequest::getDatabaseTableName() . " LIKE 'token'")) {
|
299 |
+
$query = "ALTER TABLE `" . AccessRequest::getDatabaseTableName() . "`
|
300 |
ADD column `token` text NOT NULL AFTER `ip_address`;";
|
301 |
+
$wpdb->query($query);
|
302 |
+
update_option('wpgdprc_db_version', '1.5');
|
303 |
+
} else {
|
304 |
+
update_option('wpgdprc_db_version', '1.5');
|
305 |
+
}
|
306 |
+
}
|
307 |
+
}
|
308 |
+
|
309 |
+
// Create log table
|
310 |
+
if (version_compare($dbVersion, '1.6', '<')) {
|
311 |
+
if ($wpdb->get_var("SHOW TABLES LIKE " . $wpdb->prefix . "wpgdprc_log") !== $wpdb->prefix . 'wpgdprc_log') {
|
312 |
+
$sql = 'CREATE TABLE ' . $wpdb->prefix . 'wpgdprc_log(
|
313 |
ID BIGINT NOT NULL AUTO_INCREMENT,
|
314 |
plugin_id VARCHAR(255) NULL,
|
315 |
form_id VARCHAR(255) NULL,
|
321 |
PRIMARY KEY (ID))
|
322 |
CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci';
|
323 |
|
324 |
+
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
325 |
+
dbDelta($sql);
|
326 |
+
update_option('wpgdprc_db_version', '1.6');
|
327 |
+
}
|
328 |
+
}
|
329 |
}
|
330 |
|
331 |
/**
|