complianz-gdpr
Last commit date
DNSMPD
2 months ago
assets
1 month ago
config
2 months ago
cookie
1 month ago
cookiebanner
1 month ago
cron
7 months ago
documents
2 months ago
gutenberg
1 month ago
integrations
1 month ago
languages
1 month ago
mailer
1 year ago
onboarding
1 year ago
placeholders
7 months ago
progress
2 years ago
proof-of-consent
1 month ago
rest-api
1 month ago
settings
1 month ago
templates
6 months ago
upgrade
1 month ago
websitescan
2 months ago
LICENSE.txt
4 years ago
README.md
7 months ago
class-admin.php
6 months ago
class-company.php
2 years ago
class-cookie-blocker.php
7 months ago
class-export.php
2 years ago
class-installer.php
2 years ago
class-review.php
11 months ago
complianz-gpdr.php
1 month ago
functions-legacy.php
2 years ago
functions.php
2 months ago
index.php
7 years ago
loco.xml
4 years ago
readme.txt
1 month ago
security.md
2 years ago
system-status.php
1 year ago
uninstall.php
1 month ago
upgrade.php
2 months ago
upgrade.php
1049 lines
| 1 | <?php |
| 2 | defined( 'ABSPATH' ) or die(); |
| 3 | add_action( 'init', 'cmplz_check_upgrade', 10, 2 ); |
| 4 | |
| 5 | /** |
| 6 | * Run an upgrade procedure if the version has changed |
| 7 | */ |
| 8 | function cmplz_check_upgrade() { |
| 9 | #only run upgrade check if cron, or if admin. |
| 10 | if ( !is_admin() && !wp_doing_cron() ) { |
| 11 | return; |
| 12 | } |
| 13 | |
| 14 | $prev_version = get_option( 'cmplz-current-version', false ); |
| 15 | $force = isset( $_GET['cmplz_upgrade'] ) && cmplz_user_can_manage(); |
| 16 | $new_version = CMPLZ_VERSION; |
| 17 | //strip off everything after '#' |
| 18 | if ( strpos( $new_version, '#' ) !== false ) { |
| 19 | $new_version = substr( $new_version, 0, strpos( $new_version, '#' ) ); |
| 20 | } |
| 21 | |
| 22 | if ( !$force && $prev_version === $new_version ) { |
| 23 | return; |
| 24 | } |
| 25 | |
| 26 | //trigger table upgrades |
| 27 | do_action("cmplz_install_tables"); |
| 28 | |
| 29 | /** |
| 30 | * Set a "first version" variable, so we can check if some notices need to be shown |
| 31 | */ |
| 32 | if ( ! $prev_version ) { |
| 33 | update_option( 'cmplz_first_version', $new_version, false ); |
| 34 | } |
| 35 | |
| 36 | /* |
| 37 | * change googlemaps into google-maps |
| 38 | * */ |
| 39 | if ( $prev_version |
| 40 | && version_compare( $prev_version, '4.0.0', '<' ) |
| 41 | ) { |
| 42 | $wizard_settings = get_option( 'complianz_options_wizard' ); |
| 43 | if ( isset( $wizard_settings['thirdparty_services_on_site']['googlemaps'] ) |
| 44 | && $wizard_settings['thirdparty_services_on_site']['googlemaps'] |
| 45 | == 1 |
| 46 | ) { |
| 47 | unset( $wizard_settings['thirdparty_services_on_site']['googlemaps'] ); |
| 48 | $wizard_settings['thirdparty_services_on_site']['google-maps'] = 1; |
| 49 | update_option( 'complianz_options_wizard', $wizard_settings ); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * upgrade existing eu and uk settings to separate uk optinstats |
| 55 | */ |
| 56 | |
| 57 | if ( $prev_version |
| 58 | && version_compare( $prev_version, '4.0.0', '<' ) |
| 59 | ) { |
| 60 | if ( cmplz_has_region( 'eu' ) && cmplz_has_region( 'uk' ) ) { |
| 61 | $banners = cmplz_get_cookiebanners(); |
| 62 | foreach ( $banners as $banner ) { |
| 63 | $banner = cmplz_get_cookiebanner( $banner->ID ); |
| 64 | $banner->use_categories_optinstats |
| 65 | = $banner->use_categories; |
| 66 | $banner->save(); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * migrate to anonymous if anonymous settings are selected |
| 74 | */ |
| 75 | |
| 76 | if ( $prev_version |
| 77 | && version_compare( $prev_version, '4.0.4', '<' ) |
| 78 | ) { |
| 79 | $selected_stat_service = cmplz_get_option( 'compile_statistics' ); |
| 80 | if ( $selected_stat_service === 'google-analytics' |
| 81 | || $selected_stat_service === 'matomo' |
| 82 | || $selected_stat_service === 'google-tag-manager' |
| 83 | ) { |
| 84 | $service_name |
| 85 | = COMPLIANZ::$banner_loader->convert_slug_to_name( $selected_stat_service ); |
| 86 | |
| 87 | //check if we have other types of this service, to prevent double services here. |
| 88 | $service_anonymized = new CMPLZ_SERVICE( $service_name . ' (anonymized)' ); |
| 89 | $service = new CMPLZ_SERVICE( $service_name ); |
| 90 | |
| 91 | //check if we have two service types. If so, just delete the anonymized one |
| 92 | if ( $service_anonymized->ID && $service->ID ) { |
| 93 | $service_anonymized->delete(); |
| 94 | } else if ( $service_anonymized->ID && ! $service->ID ) { |
| 95 | //just one. If it's the anonymous service, rename, and save it. |
| 96 | $service_anonymized->name = $service_name; |
| 97 | $service_anonymized->save(); |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | |
| 103 | /** |
| 104 | * upgrade publish date to more generic unix |
| 105 | */ |
| 106 | |
| 107 | if ( $prev_version |
| 108 | && version_compare( $prev_version, '4.2', '<' ) |
| 109 | ) { |
| 110 | $publish_date = strtotime( get_option( 'cmplz_publish_date' ) ); |
| 111 | if ( intval( $publish_date ) > 0 ) { |
| 112 | update_option( 'cmplz_publish_date', |
| 113 | intval( $publish_date ) ); |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * upgrade to new custom and generated document settings |
| 119 | */ |
| 120 | if ( $prev_version |
| 121 | && version_compare( $prev_version, '4.4.0', '<' ) |
| 122 | ) { |
| 123 | //upgrade cookie policy setting to new field |
| 124 | $wizard_settings = get_option( 'complianz_options_wizard' ); |
| 125 | if ( isset( $wizard_settings["cookie-policy-type"] ) ) { |
| 126 | $value = $wizard_settings["cookie-policy-type"]; |
| 127 | unset( $wizard_settings["cookie-policy-type"] ); |
| 128 | //upgrade cookie policy custom url |
| 129 | if ( $value === 'custom' ) { |
| 130 | $url = cmplz_get_option( 'custom-cookie-policy-url' ); |
| 131 | update_option( "cmplz_cookie-statement_custom_page", $url ); |
| 132 | unset( $wizard_settings["custom-cookie-policy-url"] ); |
| 133 | } else { |
| 134 | $value = 'generated'; |
| 135 | } |
| 136 | } else { |
| 137 | $value = 'generated'; |
| 138 | } |
| 139 | |
| 140 | $wizard_settings['cookie-statement'] = $value; |
| 141 | $wizard_settings['impressum'] = 'none'; |
| 142 | |
| 143 | //upgrade privacy statement settings |
| 144 | $value = $wizard_settings["privacy-statement"]; |
| 145 | |
| 146 | if ( $value === 'yes' ) { |
| 147 | $value = 'generated'; |
| 148 | } else { |
| 149 | $wp_privacy_policy = get_option( 'wp_page_for_privacy_policy' ); |
| 150 | if ( $wp_privacy_policy ) { |
| 151 | $value = 'custom'; |
| 152 | update_option( "cmplz_privacy-statement_custom_page", $wp_privacy_policy ); |
| 153 | } else { |
| 154 | $value = 'none'; |
| 155 | } |
| 156 | } |
| 157 | $wizard_settings['privacy-statement'] = $value; |
| 158 | |
| 159 | //upgrade disclaimer settings |
| 160 | $value = $wizard_settings["disclaimer"]; |
| 161 | if ( $value === 'yes' ) { |
| 162 | $value = 'generated'; |
| 163 | } else { |
| 164 | $value = 'none'; |
| 165 | } |
| 166 | $wizard_settings['disclaimer'] = $value; |
| 167 | |
| 168 | //save the data |
| 169 | update_option( 'complianz_options_wizard', $wizard_settings ); |
| 170 | } |
| 171 | |
| 172 | /** |
| 173 | * upgrade to new category field |
| 174 | */ |
| 175 | if ( $prev_version |
| 176 | && version_compare( $prev_version, '4.6.0', '<' ) |
| 177 | ) { |
| 178 | |
| 179 | $banners = cmplz_get_cookiebanners(); |
| 180 | if ( $banners ) { |
| 181 | foreach ( $banners as $banner_item ) { |
| 182 | $banner = new CMPLZ_COOKIEBANNER( $banner_item->ID, false ); |
| 183 | $banner->banner_version ++; |
| 184 | if ( $banner->use_categories ) { |
| 185 | $banner->use_categories = 'legacy'; |
| 186 | } else { |
| 187 | $banner->use_categories = 'no'; |
| 188 | } |
| 189 | if ( $banner->use_categories_optinstats ) { |
| 190 | $banner->use_categories_optinstats = 'legacy'; |
| 191 | } else { |
| 192 | $banner->use_categories_optinstats = 'no'; |
| 193 | } |
| 194 | //also set the deny button to banner color, to make sure users start with correct colors |
| 195 | $banner->functional_background_color = $banner->colorpalette_background['color']; |
| 196 | $banner->functional_border_color = $banner->colorpalette_background['border']; |
| 197 | $banner->functional_text_color = $banner->colorpalette_text['color']; |
| 198 | $banner->save(); |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | /** |
| 204 | * migrate policy id to network option for multisites |
| 205 | */ |
| 206 | |
| 207 | if ( $prev_version && version_compare( $prev_version, '4.6.7', '<' ) |
| 208 | ) { |
| 209 | if ( is_multisite() ) { |
| 210 | update_site_option( 'complianz_active_policy_id', get_option( 'complianz_active_policy_id', 1 ) ); |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | /** |
| 215 | * migrate odd numbers |
| 216 | */ |
| 217 | if ( $prev_version && version_compare( $prev_version, '4.6.8', '<' ) |
| 218 | ) { |
| 219 | $banners = cmplz_get_cookiebanners(); |
| 220 | if ( $banners ) { |
| 221 | foreach ( $banners as $banner_item ) { |
| 222 | $banner = cmplz_get_cookiebanner( $banner_item->ID ); |
| 223 | if ( $banner->banner_width % 2 == 1 ) { |
| 224 | $banner->banner_width ++; |
| 225 | } |
| 226 | $banner->save(); |
| 227 | } |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | if ( $prev_version |
| 232 | && version_compare( $prev_version, '4.7.1', '<' ) |
| 233 | ) { |
| 234 | //upgrade cookie policy setting to new field |
| 235 | $wizard_settings = get_option( 'complianz_options_wizard' ); |
| 236 | $wizard_settings['block_recaptcha_service'] = 'yes'; |
| 237 | update_option( 'complianz_options_wizard', $wizard_settings ); |
| 238 | } |
| 239 | |
| 240 | if ( $prev_version |
| 241 | && version_compare( $prev_version, '4.9.6', '<' ) |
| 242 | ) { |
| 243 | //this branch aims to revoke consent and clear all cookies. We increase the policy id to do this. |
| 244 | COMPLIANZ::$banner_loader->upgrade_active_policy_id(); |
| 245 | } |
| 246 | |
| 247 | /** |
| 248 | * upgrade to new cookie banner, and 5.0 message option |
| 249 | */ |
| 250 | |
| 251 | if ( $prev_version && version_compare( $prev_version, '5.0.0', '<' ) ) { |
| 252 | update_option( 'cmplz_upgraded_to_five', true, false ); |
| 253 | |
| 254 | //clear notices cache, as the array structure has changed |
| 255 | delete_transient( 'complianz_warnings' ); |
| 256 | global $wpdb; |
| 257 | |
| 258 | $banners = cmplz_get_cookiebanners(); |
| 259 | if ( $banners ) { |
| 260 | foreach ( $banners as $banner_item ) { |
| 261 | $banner = new CMPLZ_COOKIEBANNER( $banner_item->ID, false ); |
| 262 | $sql = $wpdb->prepare("select * from {$wpdb->prefix}cmplz_cookiebanners where ID = %s", $banner_item->ID); |
| 263 | $result = $wpdb->get_row( $sql ); |
| 264 | |
| 265 | if ( $result ) { |
| 266 | //reset to arrays |
| 267 | if (!is_array($banner->colorpalette_background)) { |
| 268 | $banner->colorpalette_background = array(); |
| 269 | } |
| 270 | if (!is_array($banner->colorpalette_text)) { |
| 271 | $banner->colorpalette_text = array(); |
| 272 | } |
| 273 | if (!is_array($banner->colorpalette_toggles)) { |
| 274 | $banner->colorpalette_toggles = array(); |
| 275 | } |
| 276 | if (!is_array($banner->colorpalette_button_accept)) { |
| 277 | $banner->colorpalette_button_accept = array(); |
| 278 | } |
| 279 | if (!is_array($banner->colorpalette_button_deny)) { |
| 280 | $banner->colorpalette_button_deny = array(); |
| 281 | } |
| 282 | if (!is_array($banner->colorpalette_button_settings)) { |
| 283 | $banner->colorpalette_button_settings = array(); |
| 284 | } |
| 285 | $banner->colorpalette_background['color'] = empty( $result->popup_background_color ) ? '#f1f1f1' : $result->popup_background_color; |
| 286 | $banner->colorpalette_background['border'] = empty( $result->popup_background_color ) ? '#f1f1f1' : $result->popup_background_color; |
| 287 | $banner->colorpalette_text['color'] = empty( $result->popup_text_color ) ? '#191e23' : $result->popup_text_color; |
| 288 | $banner->colorpalette_text['hyperlink'] = empty( $result->popup_text_color ) ? '#191e23' : $result->popup_text_color; |
| 289 | $banner->colorpalette_toggles['background'] = empty( $result->slider_background_color ) ? '#21759b' : $result->slider_background_color; |
| 290 | $banner->colorpalette_toggles['bullet'] = empty( $result->slider_bullet_color ) ? '#ffffff' : $result->slider_bullet_color; |
| 291 | $banner->colorpalette_toggles['inactive'] = empty( $result->slider_background_color_inactive ) ? '#F56E28' : $result->slider_background_color_inactive; |
| 292 | |
| 293 | $consenttypes = cmplz_get_used_consenttypes(); |
| 294 | $optout_only = false; |
| 295 | if ( in_array( 'optout', $consenttypes ) && count( $consenttypes ) === 1 ) { |
| 296 | $optout_only = true; |
| 297 | } |
| 298 | |
| 299 | if ( $banner->use_categories === 'no' || $optout_only ) { |
| 300 | $banner->colorpalette_button_accept['background'] = empty( $result->button_background_color ) ? '#21759b' : $result->button_background_color; |
| 301 | $banner->colorpalette_button_accept['border'] = empty( $result->border_color ) ? '#21759b' : $result->border_color; |
| 302 | $banner->colorpalette_button_accept['text'] = empty( $result->button_text_color ) ? '#ffffff' : $result->button_text_color; |
| 303 | } else { |
| 304 | $banner->colorpalette_button_accept['background'] = empty( $result->accept_all_background_color ) ? '#21759b' : $result->accept_all_background_color; |
| 305 | $banner->colorpalette_button_accept['border'] = empty( $result->accept_all_border_color ) ? '#21759b' : $result->accept_all_border_color; |
| 306 | $banner->colorpalette_button_accept['text'] = empty( $result->accept_all_text_color ) ? '#ffffff' : $result->accept_all_text_color; |
| 307 | } |
| 308 | $banner->colorpalette_button_deny['background'] = empty( $result->functional_background_color ) ? '#f1f1f1' : $result->functional_background_color; |
| 309 | $banner->colorpalette_button_deny['border'] = empty( $result->functional_border_color ) ? '#f1f1f1' : $result->functional_border_color; |
| 310 | $banner->colorpalette_button_deny['text'] = empty( $result->functional_text_color ) ? '#21759b' : $result->functional_text_color; |
| 311 | |
| 312 | $banner->colorpalette_button_settings['background'] = empty( $result->button_background_color ) ? '#f1f1f1' : $result->button_background_color; |
| 313 | $banner->colorpalette_button_settings['border'] = empty( $result->border_color ) ? '#21759b' : $result->border_color; |
| 314 | $banner->colorpalette_button_settings['text'] = empty( $result->button_text_color ) ? '#21759b' : $result->button_text_color; |
| 315 | if ( $banner->theme === 'edgeless' ) { |
| 316 | $banner->buttons_border_radius = array( |
| 317 | 'top' => '0', |
| 318 | 'right' => '0', |
| 319 | 'bottom' => '0', |
| 320 | 'left' => '0', |
| 321 | 'type' => 'px', |
| 322 | ); |
| 323 | } |
| 324 | |
| 325 | $banner->save(); |
| 326 | } |
| 327 | |
| 328 | } |
| 329 | } |
| 330 | /** |
| 331 | * Move custom scripts from 'wizard' to 'custom-scripts' |
| 332 | */ |
| 333 | //upgrade cookie policy setting to new field |
| 334 | $wizard_settings = get_option( 'complianz_options_wizard' ); |
| 335 | $custom_scripts = array(); |
| 336 | if ( isset( $wizard_settings['statistics_script'] ) ) { |
| 337 | $custom_scripts['statistics_script'] = $wizard_settings['statistics_script']; |
| 338 | } |
| 339 | if ( isset( $wizard_settings['cookie_scripts'] ) ) { |
| 340 | $custom_scripts['cookie_scripts'] = $wizard_settings['cookie_scripts']; |
| 341 | } |
| 342 | if ( isset( $wizard_settings['cookie_scripts_async'] ) ) { |
| 343 | $custom_scripts['cookie_scripts_async'] = $wizard_settings['cookie_scripts_async']; |
| 344 | } |
| 345 | if ( isset( $wizard_settings['thirdparty_scripts'] ) ) { |
| 346 | $custom_scripts['thirdparty_scripts'] = $wizard_settings['thirdparty_scripts']; |
| 347 | } |
| 348 | if ( isset( $wizard_settings['thirdparty_iframes'] ) ) { |
| 349 | $custom_scripts['thirdparty_iframes'] = $wizard_settings['thirdparty_iframes']; |
| 350 | } |
| 351 | unset( $wizard_settings['statistics_script'] ); |
| 352 | unset( $wizard_settings['cookie_scripts'] ); |
| 353 | unset( $wizard_settings['cookie_scripts_async'] ); |
| 354 | unset( $wizard_settings['thirdparty_scripts'] ); |
| 355 | unset( $wizard_settings['thirdparty_iframes'] ); |
| 356 | update_option( 'complianz_options_custom-scripts', $custom_scripts ); |
| 357 | update_option( 'complianz_options_wizard', $wizard_settings ); |
| 358 | } |
| 359 | |
| 360 | if ( $prev_version && version_compare( $prev_version, '5.1.0', '<' ) ) { |
| 361 | update_option( 'cmplz_first_version', '5.0.0', false ); |
| 362 | } |
| 363 | |
| 364 | /** |
| 365 | * restore dropshadow in TCF banner. |
| 366 | */ |
| 367 | if ( $prev_version |
| 368 | && version_compare( $prev_version, '5.1.2', '<' ) |
| 369 | ) { |
| 370 | if ( cmplz_tcf_active() ) { |
| 371 | $banners = cmplz_get_cookiebanners(); |
| 372 | if ( $banners ) { |
| 373 | foreach ( $banners as $banner_item ) { |
| 374 | $banner = new CMPLZ_COOKIEBANNER( $banner_item->ID, false ); |
| 375 | $banner->use_box_shadow = true; |
| 376 | $banner->save(); |
| 377 | } |
| 378 | } |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | if ( $prev_version |
| 383 | && version_compare( $prev_version, '5.2.0', '<' ) |
| 384 | ) { |
| 385 | if ( cmplz_tcf_active() ) { |
| 386 | $banners = cmplz_get_cookiebanners(); |
| 387 | if ( $banners ) { |
| 388 | foreach ( $banners as $banner_item ) { |
| 389 | $banner = new CMPLZ_COOKIEBANNER( $banner_item->ID, false ); |
| 390 | $banner->colorpalette_button_accept = array( |
| 391 | 'background' => '#333', |
| 392 | 'border' => '#333', |
| 393 | 'text' => '#fff', |
| 394 | ); |
| 395 | $banner->colorpalette_button_settings = array( |
| 396 | 'background' => '#fff', |
| 397 | 'border' => '#333', |
| 398 | 'text' => '#333', |
| 399 | ); |
| 400 | $banner->save(); |
| 401 | } |
| 402 | } |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | /** |
| 407 | * Change metakeys for eu dataleaks from '{metakey}' to '{metakey}-eu' for consistency between dataleaks . |
| 408 | */ |
| 409 | if ( $prev_version |
| 410 | && version_compare( $prev_version, '5.4.0', '<' ) |
| 411 | ) { |
| 412 | $args = array( |
| 413 | 'numberposts' => - 1, |
| 414 | 'post_type' => 'cmplz-dataleak', |
| 415 | 'tax_query' => array( |
| 416 | array( |
| 417 | 'taxonomy' => 'cmplz-region', |
| 418 | 'field' => 'slug', |
| 419 | 'terms' => 'eu', |
| 420 | ), |
| 421 | ), |
| 422 | ); |
| 423 | |
| 424 | $posts = get_posts( $args ); |
| 425 | $meta_keys = array( |
| 426 | 'security-incident-occurred', |
| 427 | 'type-of-dataloss', |
| 428 | 'reach-of-dataloss', |
| 429 | 'risk-of-data-loss', |
| 430 | 'what-occurred', |
| 431 | 'consequences', |
| 432 | 'measures', |
| 433 | 'measures_by_person_involved', |
| 434 | 'conclusion', |
| 435 | ); |
| 436 | foreach ( $posts as $post ) { |
| 437 | foreach ( $meta_keys as $meta_key ) { |
| 438 | $value = get_post_meta( $post->ID, $meta_key, true ); |
| 439 | if ( $value ) { |
| 440 | update_post_meta( $post->ID, $meta_key . '-eu', $value ); |
| 441 | } |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | $wizard_settings = get_option( 'complianz_options_wizard' ); |
| 446 | //upgrade to checkboxes structure. |
| 447 | $value_eu = $value_uk = false; |
| 448 | if ( isset( $wizard_settings['dpo_or_gdpr'] ) ) { |
| 449 | $value_eu = $wizard_settings['dpo_or_gdpr']; |
| 450 | } |
| 451 | |
| 452 | if ( isset( $wizard_settings['dpo_or_uk_gdpr'] ) ) { |
| 453 | $value_uk = $wizard_settings['dpo_or_uk_gdpr']; |
| 454 | } |
| 455 | if ( ! is_array( $value_eu ) ) { |
| 456 | $new_value = array( |
| 457 | 'dpo' => 0, |
| 458 | 'dpo_uk' => 0, |
| 459 | 'gdpr_rep' => 0, |
| 460 | 'uk_gdpr_rep' => 0, |
| 461 | ); |
| 462 | if ( $value_eu ) { |
| 463 | $new_value[ $value_eu ] = 1; |
| 464 | } |
| 465 | if ( $value_uk ) { |
| 466 | if ( $value_uk === 'dpo' ) { |
| 467 | $value_uk = 'dpo_uk'; |
| 468 | } |
| 469 | $new_value[ $value_uk ] = 1; |
| 470 | } |
| 471 | //none is not applicable anymore, as it's multischeckbox |
| 472 | unset( $new_value['none'] ); |
| 473 | |
| 474 | $wizard_settings['dpo_or_gdpr'] = $new_value; |
| 475 | unset( $wizard_settings['dpo_or_uk_gdpr'] ); |
| 476 | |
| 477 | if ( isset( $wizard_settings['ca_name_address_accountable_person'] ) ) { |
| 478 | $address = preg_split( '#\n(?!s)#', $wizard_settings['ca_name_address_accountable_person'] ); |
| 479 | $name = isset( $address[0] ) ? $address[0] : ''; |
| 480 | unset( $address[0] ); |
| 481 | $address = implode( "\n", $address ); |
| 482 | $wizard_settings['ca_name_accountable_person'] = $name; |
| 483 | $wizard_settings['ca_address_accountable_person'] = $address; |
| 484 | } |
| 485 | |
| 486 | update_option( 'complianz_options_wizard', $wizard_settings ); |
| 487 | } |
| 488 | } |
| 489 | |
| 490 | if ( $prev_version |
| 491 | && version_compare( $prev_version, '5.5.0', '<' ) |
| 492 | ) { |
| 493 | $wizard_settings = get_option( 'complianz_options_wizard' ); |
| 494 | $settings_settings = get_option( 'complianz_options_settings' ); |
| 495 | if ( isset( $wizard_settings['use_cdb_api'] ) ) { |
| 496 | $settings_settings['use_cdb_api'] = $wizard_settings['use_cdb_api']; |
| 497 | $settings_settings['use_cdb_links'] = $wizard_settings['use_cdb_links']; |
| 498 | } |
| 499 | unset( $wizard_settings['use_cdb_api'] ); |
| 500 | unset( $wizard_settings['use_cdb_links'] ); |
| 501 | update_option( 'complianz_options_wizard', $wizard_settings ); |
| 502 | update_option( 'complianz_options_settings', $settings_settings ); |
| 503 | } |
| 504 | |
| 505 | if ( $prev_version |
| 506 | && version_compare( $prev_version, '5.5.0', '<' ) |
| 507 | ) { |
| 508 | $wizard_settings = get_option( 'complianz_options_wizard' ); |
| 509 | |
| 510 | $share_data_us = $share_data_eu = 2; |
| 511 | if ( isset($wizard_settings['share_data_other_us']) ) { |
| 512 | $share_data_us = intval($wizard_settings['share_data_other_us']); |
| 513 | } |
| 514 | if ( isset($wizard_settings['share_data_other']) ) { |
| 515 | $share_data_eu = intval($wizard_settings['share_data_other']); |
| 516 | } |
| 517 | //share data other parties: indien een van beide "yes", nieuwe yes. Indien een van beide limited, nieuwe "limited". anders no. |
| 518 | if ($share_data_us===1 || $share_data_eu ===1) { |
| 519 | $share_data = 1; |
| 520 | } else if ($share_data_us===3 || $share_data_eu ===3){ |
| 521 | $share_data = 3; |
| 522 | } else { |
| 523 | $share_data = 2; |
| 524 | } |
| 525 | $wizard_settings['share_data_other'] = $share_data; |
| 526 | $us_processors = isset($wizard_settings['processor_us'] ) ? $wizard_settings['processor_us'] : array(); |
| 527 | $eu_processors = isset($wizard_settings['processor']) ? $wizard_settings['processor'] : array(); |
| 528 | foreach ( $us_processors as $us_processor ) { |
| 529 | //check if it's already in the list |
| 530 | $key = array_search($us_processor['name'], array_column($eu_processors, 'name')); |
| 531 | if ( $key !== false ) unset($us_processors[ $key ]); |
| 532 | } |
| 533 | |
| 534 | //now add the remaining values to the EU list |
| 535 | $eu_processors = array_merge($eu_processors, $us_processors); |
| 536 | $wizard_settings['processor'] = $eu_processors; |
| 537 | |
| 538 | $us_thirdparties = isset($wizard_settings['thirdparty_us'] ) ? $wizard_settings['thirdparty_us'] : array(); |
| 539 | $eu_thirdparties = isset($wizard_settings['thirdparty']) ? $wizard_settings['thirdparty'] : array(); |
| 540 | foreach ( $us_thirdparties as $us_thirdparty ) { |
| 541 | //check if it's already in the list |
| 542 | $key = array_search($us_thirdparty['name'], array_column($eu_thirdparties, 'name')); |
| 543 | if ( $key !== false ) unset($us_thirdparties[ $key ]); |
| 544 | } |
| 545 | //now add the remaining values to the EU list |
| 546 | $eu_thirdparties = array_merge($eu_thirdparties, $us_thirdparties); |
| 547 | $wizard_settings['thirdparty'] = $eu_thirdparties; |
| 548 | unset($wizard_settings['thirdparty_us']); |
| 549 | unset($wizard_settings['processor_us']); |
| 550 | |
| 551 | update_option( 'complianz_options_wizard', $wizard_settings ); |
| 552 | } |
| 553 | |
| 554 | if ( $prev_version && version_compare( $prev_version, '6.0.0', '<' ) ) { |
| 555 | $custom_scripts = get_option( 'complianz_options_custom-scripts' ); |
| 556 | |
| 557 | $scripts['add_script'] = []; |
| 558 | $scripts['block_script'] = []; |
| 559 | $scripts['whitelist_script'] = []; |
| 560 | |
| 561 | if ( ! empty( $custom_scripts['cookie_scripts'] ) ) { |
| 562 | $scripts['add_script'][] = [ |
| 563 | 'name' => 'Scripts', |
| 564 | 'editor' => $custom_scripts['cookie_scripts'], |
| 565 | 'async' => '0', |
| 566 | 'category' => 'marketing', |
| 567 | 'enable_placeholder' => '0', |
| 568 | 'placeholder_class' => '', |
| 569 | 'placeholder' => '', |
| 570 | 'enable_dependency' => '0', |
| 571 | 'dependency' => '', |
| 572 | 'enable' => '1', |
| 573 | ]; |
| 574 | } |
| 575 | |
| 576 | if ( ! empty( $custom_scripts['cookie_scripts_async'] ) ) { |
| 577 | $scripts['add_script'][] = [ |
| 578 | 'name' => 'Async scripts', |
| 579 | 'editor' => $custom_scripts['cookie_scripts_async'], |
| 580 | 'async' => '1', |
| 581 | 'category' => 'marketing', |
| 582 | 'enable_placeholder' => '0', |
| 583 | 'placeholder_class' => '', |
| 584 | 'placeholder' => '', |
| 585 | 'enable_dependency' => '0', |
| 586 | 'dependency' => '', |
| 587 | 'enable' => '1', |
| 588 | ]; |
| 589 | } |
| 590 | |
| 591 | if ( ! empty( $custom_scripts['statistics_script'] ) ) { |
| 592 | $scripts['add_script'][] = [ |
| 593 | 'name' => 'Statistics scripts', |
| 594 | 'editor' => $custom_scripts['statistics_script'], |
| 595 | 'async' => '0', |
| 596 | 'category' => 'statistics', |
| 597 | 'enable_placeholder' => '0', |
| 598 | 'placeholder_class' => '', |
| 599 | 'placeholder' => '', |
| 600 | 'enable_dependency' => '0', |
| 601 | 'dependency' => '', |
| 602 | 'enable' => '1', |
| 603 | ]; |
| 604 | } |
| 605 | |
| 606 | if ( ! empty( $custom_scripts['thirdparty_scripts'] ) ) { |
| 607 | $scripts['block_script'][] = [ |
| 608 | 'name' => 'Third party scripts', |
| 609 | 'urls' => explode( ',', $custom_scripts['thirdparty_scripts'] ), |
| 610 | 'category' => 'marketing', |
| 611 | 'enable_placeholder' => '0', |
| 612 | 'placeholder_class' => '', |
| 613 | 'placeholder' => '', |
| 614 | 'enable' => '1', |
| 615 | ]; |
| 616 | } |
| 617 | |
| 618 | if ( ! empty( $custom_scripts['thirdparty_iframes'] ) ) { |
| 619 | $scripts['block_script'][] = [ |
| 620 | 'name' => 'Third party iframes', |
| 621 | 'urls' => explode( ',', $custom_scripts['thirdparty_iframes'] ), |
| 622 | 'category' => 'marketing', |
| 623 | 'enable_placeholder' => '0', |
| 624 | 'placeholder_class' => '', |
| 625 | 'placeholder' => '', |
| 626 | 'enable' => '1', |
| 627 | ]; |
| 628 | } |
| 629 | update_option( 'complianz_options_custom-scripts', $scripts ); |
| 630 | |
| 631 | $banners = cmplz_get_cookiebanners(); |
| 632 | if ( $banners ) { |
| 633 | foreach ( $banners as $banner_item ) { |
| 634 | $banner = new CMPLZ_COOKIEBANNER( $banner_item->ID ); |
| 635 | switch ( $banner->use_categories ) { |
| 636 | case 'no': |
| 637 | $banner->use_categories = 'no'; |
| 638 | break; |
| 639 | case 'legacy': |
| 640 | case 'visible': |
| 641 | $banner->use_categories = 'save-preferences'; |
| 642 | break; |
| 643 | default: |
| 644 | $banner->use_categories = 'view-preferences'; |
| 645 | } |
| 646 | |
| 647 | switch ( $banner->position ) { |
| 648 | case 'top': |
| 649 | $banner->position = 'bottom'; |
| 650 | break; |
| 651 | case 'bottom': |
| 652 | case 'bottom-left': |
| 653 | case 'bottom-right': |
| 654 | break; |
| 655 | default: |
| 656 | $banner->position = 'center'; |
| 657 | } |
| 658 | |
| 659 | switch ( $banner->checkbox_style ) { |
| 660 | case 'classic': |
| 661 | $banner->checkbox_style = 'classic'; |
| 662 | break; |
| 663 | default: |
| 664 | $banner->checkbox_style = 'slider'; |
| 665 | } |
| 666 | |
| 667 | if ( !is_serialized($banner->border_width) ) { |
| 668 | $banner->border_width = array( |
| 669 | 'top' => 0, |
| 670 | 'right' => 0, |
| 671 | 'bottom' => 0, |
| 672 | 'left' => 0, |
| 673 | ); |
| 674 | } |
| 675 | |
| 676 | if ( !isset($banner->border_width['top']) ) $banner->border_width['top'] = 0; |
| 677 | if ( !isset($banner->border_width['right']) ) $banner->border_width['right'] = 0; |
| 678 | if ( !isset($banner->border_width['bottom']) ) $banner->border_width['bottom'] = 0; |
| 679 | if ( !isset($banner->border_width['left']) ) $banner->border_width['left'] = 0; |
| 680 | |
| 681 | if (!is_serialized($banner_item->dismiss)) { |
| 682 | $banner->revoke = array( |
| 683 | 'text' => $banner_item->revoke, |
| 684 | 'show' => ! $banner_item->hide_revoke, |
| 685 | ); |
| 686 | } |
| 687 | |
| 688 | if (!is_serialized($banner_item->header) ) { |
| 689 | if ( strlen($banner_item->header)<4 ) { |
| 690 | $banner->header = array( |
| 691 | 'text' => '', |
| 692 | 'show' => false, |
| 693 | ); |
| 694 | } else { |
| 695 | $banner->header = array( |
| 696 | 'text' => $banner_item->header, |
| 697 | 'show' => true, |
| 698 | ); |
| 699 | } |
| 700 | } |
| 701 | |
| 702 | if (!is_serialized($banner_item->accept_informational)) { |
| 703 | $banner->accept_informational = array( |
| 704 | 'text' => $banner_item->accept_informational, |
| 705 | 'show' => true, |
| 706 | ); |
| 707 | } |
| 708 | |
| 709 | if (!is_serialized($banner_item->category_prefs)) { |
| 710 | $banner->category_prefs = array( |
| 711 | 'text' => $banner_item->category_prefs, |
| 712 | 'show' => true, |
| 713 | ); |
| 714 | } |
| 715 | |
| 716 | if (!is_serialized($banner_item->category_stats)) { |
| 717 | $banner->category_stats = array( |
| 718 | 'text' => $banner_item->category_stats, |
| 719 | 'show' => true, |
| 720 | ); |
| 721 | } |
| 722 | |
| 723 | if (!is_serialized($banner_item->category_all)) { |
| 724 | $banner->category_all = array( |
| 725 | 'text' => $banner_item->category_all, |
| 726 | 'show' => true, |
| 727 | ); |
| 728 | } |
| 729 | |
| 730 | $banner->use_box_shadow = true; |
| 731 | $banner->use_logo = 'hide'; |
| 732 | $banner->close_button = false; |
| 733 | $banner->save(); |
| 734 | } |
| 735 | } |
| 736 | |
| 737 | $wizard_settings = get_option( 'complianz_options_wizard' ); |
| 738 | if ( isset( $wizard_settings['compile_statistics'] ) && $wizard_settings['compile_statistics'] === 'yes-anonymous' ) { |
| 739 | $wizard_settings['compile_statistics'] = 'yes'; |
| 740 | update_option( 'complianz_options_wizard', $wizard_settings ); |
| 741 | } |
| 742 | } |
| 743 | |
| 744 | if ( $prev_version && version_compare( $prev_version, '6.0.0', '>=' ) ) { |
| 745 | $warning_id = 'upgraded_to_6'; |
| 746 | $dismissed_warnings = get_option( 'cmplz_dismissed_warnings', array() ); |
| 747 | if ( !in_array($warning_id, $dismissed_warnings) ) { |
| 748 | $dismissed_warnings[] = $warning_id; |
| 749 | update_option('cmplz_dismissed_warnings', $dismissed_warnings ); |
| 750 | delete_transient('complianz_warnings'); |
| 751 | delete_transient('complianz_warnings_admin_notices'); |
| 752 | } |
| 753 | } |
| 754 | |
| 755 | if ( $prev_version && version_compare( $prev_version, '6.0.2', '<' ) ) { |
| 756 | $banners = cmplz_get_cookiebanners(); |
| 757 | if ( $banners ) { |
| 758 | foreach ( $banners as $banner_item ) { |
| 759 | $banner = new CMPLZ_COOKIEBANNER( $banner_item->ID ); |
| 760 | if ( $banner->banner_width == 476 ) { |
| 761 | $banner->banner_width = 526; |
| 762 | $banner->save(); |
| 763 | } |
| 764 | } |
| 765 | } |
| 766 | } |
| 767 | |
| 768 | if ( $prev_version && version_compare( $prev_version, '6.0.8', '<' ) ) { |
| 769 | $banners = cmplz_get_cookiebanners(); |
| 770 | if ( $banners ) { |
| 771 | foreach ( $banners as $banner_item ) { |
| 772 | $banner = new CMPLZ_COOKIEBANNER( $banner_item->ID ); |
| 773 | if ( $banner->use_categories === 'hidden' ) { |
| 774 | $banner->use_categories = 'view-preferences'; |
| 775 | $banner->save(); |
| 776 | } |
| 777 | } |
| 778 | } |
| 779 | } |
| 780 | |
| 781 | if ( $prev_version && version_compare( $prev_version, '6.1.0', '<' ) ) { |
| 782 | $banners = cmplz_get_cookiebanners(); |
| 783 | if ( $banners ) { |
| 784 | foreach ( $banners as $banner_item ) { |
| 785 | $banner = new CMPLZ_COOKIEBANNER( $banner_item->ID ); |
| 786 | $banner->legal_documents = true; |
| 787 | $banner->save(); |
| 788 | } |
| 789 | } |
| 790 | } |
| 791 | |
| 792 | if ( $prev_version && version_compare( $prev_version, '6.1.4.1', '<' ) ) { |
| 793 | $wizard_settings = get_option( 'complianz_options_wizard' ); |
| 794 | if ( isset( $wizard_settings['create_banner_elementor'] ) ) { |
| 795 | if ($wizard_settings['create_banner_elementor']==='yes' ) { |
| 796 | update_option('cmplz_elementor_banner_dropped', true); |
| 797 | } |
| 798 | $wizard_settings['create_banner_elementor'] = 'no'; |
| 799 | update_option( 'complianz_options_wizard', $wizard_settings ); |
| 800 | $post_id = get_option('cmplz_elementor_autogenerated' ); |
| 801 | $args = array( |
| 802 | 'post_status' => 'draft', |
| 803 | 'ID' => $post_id, |
| 804 | ); |
| 805 | wp_update_post($args); |
| 806 | } |
| 807 | } |
| 808 | |
| 809 | if ( $prev_version && version_compare( $prev_version, '6.2.2', '<' ) ) { |
| 810 | $wizard_settings = get_option( 'complianz_options_wizard' ); |
| 811 | if ( isset( $wizard_settings['data_request_forms'] ) ) { |
| 812 | $wizard_settings['datarequest'] = $wizard_settings['data_request_forms']; |
| 813 | unset($wizard_settings['data_request_forms']); |
| 814 | update_option( 'complianz_options_wizard', $wizard_settings ); |
| 815 | } |
| 816 | } |
| 817 | |
| 818 | // 6.3 United States Upgrade |
| 819 | if ( $prev_version && version_compare( $prev_version, '6.3.0', '<' ) ) { |
| 820 | $wizard_settings = get_option( 'complianz_options_wizard' ); |
| 821 | if ( isset( $wizard_settings['california'] ) && $wizard_settings['california'] === 'yes' ) { |
| 822 | unset( $wizard_settings['california'] ); |
| 823 | $wizard_settings['us_states']['cal'] = 1; |
| 824 | } |
| 825 | |
| 826 | $mapping_array = [ |
| 827 | '1' => [ 'first-lastname', 'address' ], |
| 828 | '2' => [ 'marital-status' ], |
| 829 | '5' => [ 'date-of-birth' ], |
| 830 | '6' => [ 'accountname-alias' ], |
| 831 | '7' => [ 'sex' ], |
| 832 | '3' => [ 'email' ], |
| 833 | '15' => [ 'phone' ], |
| 834 | '8' => [ 'ip' ], |
| 835 | '4' => [ 'financial-information' ], |
| 836 | '10' => [ 'medical' ], |
| 837 | '11' => [ 'internet' ], |
| 838 | '9' => [ 'geo' ], |
| 839 | '12' => [ 'photos' ], |
| 840 | '13' => [ 'social-media' ], |
| 841 | '14' => [ 'criminal' ], |
| 842 | ]; |
| 843 | foreach ( COMPLIANZ::$config->purposes as $key => $label ) { |
| 844 | if ( !isset($wizard_settings[$key . '_retain_data']) ) { |
| 845 | $wizard_settings[$key . '_retain_data'] = '1'; |
| 846 | } |
| 847 | |
| 848 | if (isset($wizard_settings[$key . '_data_purpose']) ) { |
| 849 | $values = $wizard_settings[$key . '_data_purpose']; |
| 850 | foreach ($values as $value => $enabled) { |
| 851 | $enabled = $enabled==='1'; |
| 852 | if ( $enabled && isset($mapping_array[ $value ])) { |
| 853 | $new_values = $mapping_array[ $value ]; |
| 854 | foreach ($new_values as $new_value ) { |
| 855 | $wizard_settings[$key . '_data_purpose_us'][$new_value] = 1; |
| 856 | } |
| 857 | } |
| 858 | } |
| 859 | unset($wizard_settings[$key . '_data_purpose']); |
| 860 | } |
| 861 | if ( isset($wizard_settings[$key . '_data_purpose_us'] ) ) { |
| 862 | $values = $wizard_settings[$key . '_data_purpose_us']; |
| 863 | foreach ($values as $value => $enabled) { |
| 864 | $enabled = $enabled==='1'; |
| 865 | if ($enabled && $value === 'any-other') { |
| 866 | unset($wizard_settings[$key . '_data_purpose_us'][$value]); |
| 867 | } |
| 868 | } |
| 869 | } |
| 870 | } |
| 871 | update_option( 'complianz_options_wizard', $wizard_settings ); |
| 872 | |
| 873 | $banners = cmplz_get_cookiebanners(); |
| 874 | if ( $banners ) { |
| 875 | foreach ( $banners as $banner_item ) { |
| 876 | $banner = new CMPLZ_COOKIEBANNER( $banner_item->ID ); |
| 877 | $revoke = $banner_item->revoke; |
| 878 | if ( is_serialized( $revoke ) ) { |
| 879 | $revoke = unserialize( $revoke ); |
| 880 | } |
| 881 | if ( isset( $revoke['text'] ) ) { |
| 882 | $banner->revoke = $revoke['text']; |
| 883 | } |
| 884 | if ( isset( $revoke['show'] ) ) { |
| 885 | if ( $revoke['show'] == '1' ) { |
| 886 | $banner->manage_consent_options = 'hover-hide-mobile'; |
| 887 | } else { |
| 888 | $banner->manage_consent_options = 'hide-everywhere'; |
| 889 | } |
| 890 | } |
| 891 | $banner->save(); |
| 892 | } |
| 893 | } |
| 894 | } |
| 895 | |
| 896 | if ( $prev_version && version_compare( $prev_version, '6.3.2', '<' ) ) { |
| 897 | //upgrade statistics a/b testing |
| 898 | $general_settings = get_option( 'complianz_options_settings' ); |
| 899 | if ( isset( $general_settings['a_b_testing'] ) && $general_settings['a_b_testing'] ) { |
| 900 | $general_settings['a_b_testing_buttons'] = true; |
| 901 | } |
| 902 | update_option( 'complianz_options_settings', $general_settings ); |
| 903 | } |
| 904 | |
| 905 | if ( $prev_version && version_compare( $prev_version, '6.3.7', '<' ) ) { |
| 906 | $wizard_settings = get_option( 'complianz_options_wizard', [] ); |
| 907 | $wizard_settings['enable_cookie_banner']='yes'; |
| 908 | $wizard_settings['enable_cookie_blocker']='yes'; |
| 909 | update_option( 'complianz_options_wizard', $wizard_settings ); |
| 910 | |
| 911 | $settings = get_option( 'complianz_options_settings', [] ); |
| 912 | $settings['safe_mode'] = $settings['disable_cookie_block'] ?? false; |
| 913 | if ( isset($settings['disable_cookie_block']) ) { |
| 914 | unset($settings['disable_cookie_block']); |
| 915 | } |
| 916 | update_option( 'complianz_options_settings', $settings ); |
| 917 | } |
| 918 | |
| 919 | // regenerate css |
| 920 | // $banners = cmplz_get_cookiebanners(); |
| 921 | // if ( $banners ) { |
| 922 | // foreach ( $banners as $banner_item ) { |
| 923 | // $banner = new CMPLZ_COOKIEBANNER( $banner_item->ID ); |
| 924 | // $banner->save(); |
| 925 | // } |
| 926 | // } |
| 927 | |
| 928 | //ensure new capability |
| 929 | if ( $prev_version && version_compare( $prev_version, '6.4.1', '<' ) ) { |
| 930 | cmplz_add_manage_privacy_capability(); |
| 931 | } |
| 932 | |
| 933 | if ( $force || ( $prev_version && version_compare( $prev_version, '7.0.0', '<' ) ) ) { |
| 934 | set_transient('cmplz_redirect_to_settings_page', true, HOUR_IN_SECONDS ); |
| 935 | //create new options array |
| 936 | $options = get_option( 'cmplz_options', [] ); |
| 937 | if ( ! is_array( $options ) ) { |
| 938 | $options = []; |
| 939 | } |
| 940 | |
| 941 | $default_id = cmplz_get_default_banner_id(); |
| 942 | $banner = new CMPLZ_COOKIEBANNER( $default_id ); |
| 943 | if ( $banner->disable_cookiebanner ) { |
| 944 | cmplz_update_option_no_hooks( 'enable_cookie_banner', 'no' ); |
| 945 | } |
| 946 | |
| 947 | $license = get_site_option( 'cmplz_license_key' ); |
| 948 | if ( $license && !is_multisite() ) { |
| 949 | $options[ 'license' ] = $license; |
| 950 | } |
| 951 | |
| 952 | $migrate_js_enabled = false; |
| 953 | $old_settings_array = [ 'complianz_options_settings', 'complianz_options_wizard' ]; |
| 954 | $wiz = get_option('complianz_options_settings'); |
| 955 | $use_country = $wiz['use_country'] ?? false; |
| 956 | foreach ( $old_settings_array as $old_setting ) { |
| 957 | $settings = get_option( $old_setting, [] ); |
| 958 | foreach ( $settings as $id => $value ) { |
| 959 | //if type is multicheckbox, change [key1 = 1, key2=1] structure to [key1, key2] |
| 960 | $id = strtolower($id); |
| 961 | $field = cmplz_get_field( $id ); |
| 962 | //tcf fields are not loaded yet, because the upgrade is not completed, so iab_enabled will always return false. |
| 963 | //as a workaround we check if the id starts with tcf_ |
| 964 | if ( strpos($id, 'tcf_') !== false ){ |
| 965 | $field = $id==='tcf_lspact' ? ['type'=>'radio'] : ['type'=>'multicheckbox']; |
| 966 | } |
| 967 | if ( $field ) { |
| 968 | $type = $field['type']; |
| 969 | //regions is default radio, but multicheckbox when use_country is enabled |
| 970 | if ($id === 'regions' && $use_country) { |
| 971 | $type = 'multicheckbox'; |
| 972 | } |
| 973 | if ($type === 'multicheckbox' && is_array( $value )) { |
| 974 | |
| 975 | $value = array_filter( $value, static function ( $item ) {return $item == 1;} ); |
| 976 | $value = array_keys( $value ); |
| 977 | } |
| 978 | if ($id === 'which_personal_data_secure') { |
| 979 | $new = []; |
| 980 | if ( isset($value['1']) || isset($value['16']) ) { |
| 981 | $new[] = '1'; |
| 982 | } |
| 983 | if ( isset($value['2']) || isset($value['4'])) { |
| 984 | $new[] = '2'; |
| 985 | } |
| 986 | if ( isset($value['3']) || isset($value['15']) ) { |
| 987 | $new[] = '3'; |
| 988 | } |
| 989 | if ( isset($value['6']) ) { |
| 990 | $new[] = '5'; |
| 991 | } |
| 992 | if ( isset($value['5']) ) { |
| 993 | $new[] = '7'; |
| 994 | } |
| 995 | if ( isset($value['7']) ) { |
| 996 | $new[] = '8'; |
| 997 | } |
| 998 | if ( isset($value['8']) || isset($value['9']) || isset($value['10']) || isset($value['11']) || isset($value['14']) || isset($value['17']) ) { |
| 999 | $new[] = '4'; |
| 1000 | } |
| 1001 | $value = $new; |
| 1002 | } |
| 1003 | $options[ $id ] = $value; |
| 1004 | } |
| 1005 | if ($id === 'enable_migrate_js' && $value) { |
| 1006 | $migrate_js_enabled = true; |
| 1007 | } |
| 1008 | } |
| 1009 | } |
| 1010 | |
| 1011 | if ( !empty($options) ){ |
| 1012 | update_option( 'cmplz_options', $options ); |
| 1013 | } |
| 1014 | |
| 1015 | if ( $migrate_js_enabled ) { |
| 1016 | $dismissed_warnings = get_option( 'cmplz_dismissed_warnings', array() ); |
| 1017 | if ( ! in_array( 'migrate_js', $dismissed_warnings ) ) { |
| 1018 | $dismissed_warnings[] = 'migrate_js'; |
| 1019 | update_option('cmplz_dismissed_warnings', $dismissed_warnings, false ); |
| 1020 | } |
| 1021 | } |
| 1022 | //set an activated time, which is used in the cookie scan and geo ip downloads |
| 1023 | update_option('cmplz_activation_time', strtotime('-1 week'), false); |
| 1024 | } |
| 1025 | |
| 1026 | //disable tcf for free users |
| 1027 | if ( $prev_version && version_compare( $prev_version, '7.0.3', '<' ) ) { |
| 1028 | $options = get_option( 'cmplz_options', [] ); |
| 1029 | if ( !defined('cmplz_premium') ) { |
| 1030 | $options['uses_ad_cookies_personalized'] = 'no'; |
| 1031 | update_option( 'cmplz_options', $options ); |
| 1032 | } |
| 1033 | } |
| 1034 | |
| 1035 | // Re-save all banners to regenerate CSS and clear caches |
| 1036 | if ( $prev_version && version_compare( $prev_version, '7.4.5', '<' ) ) { |
| 1037 | cmplz_resave_all_banners(); |
| 1038 | } |
| 1039 | |
| 1040 | #regenerate cookie policy snapshot. |
| 1041 | update_option('cmplz_generate_new_cookiepolicy_snapshot', true, false); |
| 1042 | |
| 1043 | //always clear warnings cache on update |
| 1044 | delete_transient('complianz_warnings'); |
| 1045 | delete_transient('complianz_warnings_admin_notices'); |
| 1046 | do_action( 'cmplz_upgrade', $prev_version ); |
| 1047 | update_option( 'cmplz-current-version', $new_version ); |
| 1048 | } |
| 1049 |