iubenda Cookie Solution for GDPR - Version 3.0.4

Version Description

  • Bugfix: Stop parsing code in Cookie banner
  • Bugfix: Errors on plugin update
Download this release

Release Info

Developer iubenda
Plugin Icon 128x128 iubenda Cookie Solution for GDPR
Version 3.0.4
Comparing to
See all releases

Code changes from version 3.0.3 to 3.0.4

includes/QuickGeneratorService.php CHANGED
@@ -440,10 +440,7 @@ class QuickGeneratorService
440
  if ("1" == $new_cs_option['amp_support'] && 'local' == $new_cs_option['amp_source']) {
441
 
442
  if (is_bool($template_done[$lang_id]) && false === $template_done[$lang_id]) {
443
- $message = "Currently, you do not have write permission for <i>%s</i>. For instructions on how to fix this, please read <a target=\"_blank\" href=\"%s\">our guide</a>.";
444
- $our_guide_URL = 'https://www.iubenda.com/en/help/1215-cookie-solution-wordpress-plugin-installation-guide#amp-permissions';
445
- $file_path = IUBENDA_PLUGIN_PATH . 'templates' . DIRECTORY_SEPARATOR;
446
- add_settings_error('cs_settings_errors', 'iub_cs_settings_updated', __(sprintf($message, $file_path, $our_guide_URL), 'iubenda'), 'error');
447
  }
448
  }
449
 
@@ -469,18 +466,20 @@ class QuickGeneratorService
469
  $parsed_code = iubenda()->parse_configuration(stripslashes_deep($option));
470
 
471
  // if code parsed correctly
472
- if(!$parsed_code){
473
- $codes_statues[substr($index, 5)] = false;
474
- continue;
475
- }
476
  $new_cs_option['manual_'."$index"] = $option;
477
  $codes_statues[substr($index, 5)] = true;
478
 
479
  //getting cookiePolicyId to save it into Iubenda global option
480
- $global_options['public_ids'][substr($index, 5)] = iub_array_get($parsed_code, 'cookiePolicyId');
 
 
481
 
482
  //getting site id to save it into Iubenda global option
483
- if(!$site_id){
484
  $site_id = iub_array_get($parsed_code, 'siteId');
485
  }
486
 
@@ -495,10 +494,7 @@ class QuickGeneratorService
495
  if ("1" == $new_cs_option['amp_support'] && 'local' == $new_cs_option['amp_source']) {
496
 
497
  if (is_bool($template_done[$lang_id]) && false === $template_done[$lang_id]) {
498
- $message = "Currently, you do not have write permission for <i>%s</i>. For instructions on how to fix this, please read <a target=\"_blank\" href=\"%s\">our guide</a>.";
499
- $our_guide_URL = 'https://www.iubenda.com/en/help/1215-cookie-solution-wordpress-plugin-installation-guide#amp-permissions';
500
- $file_path = IUBENDA_PLUGIN_PATH . 'templates' . DIRECTORY_SEPARATOR;
501
- add_settings_error('cs_settings_errors', 'iub_cs_settings_updated', __(sprintf($message, $file_path, $our_guide_URL), 'iubenda'), 'error');
502
  }
503
  }
504
 
@@ -597,4 +593,13 @@ class QuickGeneratorService
597
  iubenda()->options['global_options'] = $global_options;
598
  update_option( 'iubenda_global_options', $global_options );
599
  }
 
 
 
 
 
 
 
 
 
600
  }
440
  if ("1" == $new_cs_option['amp_support'] && 'local' == $new_cs_option['amp_source']) {
441
 
442
  if (is_bool($template_done[$lang_id]) && false === $template_done[$lang_id]) {
443
+ $this->add_amp_permission_error();
 
 
 
444
  }
445
  }
446
 
466
  $parsed_code = iubenda()->parse_configuration(stripslashes_deep($option));
467
 
468
  // if code parsed correctly
469
+ // if(!$parsed_code){
470
+ // $codes_statues[substr($index, 5)] = false;
471
+ // continue;
472
+ // }
473
  $new_cs_option['manual_'."$index"] = $option;
474
  $codes_statues[substr($index, 5)] = true;
475
 
476
  //getting cookiePolicyId to save it into Iubenda global option
477
+ if(iub_array_get($parsed_code, 'cookiePolicyId') ?: null){
478
+ $global_options['public_ids'][substr($index, 5)] = iub_array_get($parsed_code, 'cookiePolicyId');
479
+ }
480
 
481
  //getting site id to save it into Iubenda global option
482
+ if(!$site_id && iub_array_get($parsed_code, 'siteId') ?: null){
483
  $site_id = iub_array_get($parsed_code, 'siteId');
484
  }
485
 
494
  if ("1" == $new_cs_option['amp_support'] && 'local' == $new_cs_option['amp_source']) {
495
 
496
  if (is_bool($template_done[$lang_id]) && false === $template_done[$lang_id]) {
497
+ $this->add_amp_permission_error();
 
 
 
498
  }
499
  }
500
 
593
  iubenda()->options['global_options'] = $global_options;
594
  update_option( 'iubenda_global_options', $global_options );
595
  }
596
+
597
+ private function add_amp_permission_error()
598
+ {
599
+ $message = "Currently, you do not have write permission for <i>%s</i>. For instructions on how to fix this, please read <a target=\"_blank\" href=\"%s\">our guide</a>.";
600
+ $our_guide_URL = 'https://www.iubenda.com/en/help/1215-cookie-solution-wordpress-plugin-installation-guide#amp-permissions';
601
+ $file_path = IUBENDA_PLUGIN_PATH . 'templates' . DIRECTORY_SEPARATOR;
602
+ add_settings_error('cs_settings_errors', 'iub_cs_settings_updated', __(sprintf($message, $file_path, $our_guide_URL), 'iubenda'), 'error');
603
+ iubenda()->settings->add_notice( 'iub_integrated_success', __(sprintf($message, $file_path, $our_guide_URL), 'iubenda'), 'error' );
604
+ }
605
  }
includes/settings.php CHANGED
@@ -1009,7 +1009,7 @@ class iubenda_Settings {
1009
 
1010
  $cs_settings = [
1011
  ['label' => __('Style', 'iubenda'), 'value' => $style],
1012
- ['label' => __('Position', 'iubenda'), 'value' => ucwords(iub_array_get($banner, 'position'))],
1013
  ['label' => __('legislation', 'iubenda'), 'value' => $legislation],
1014
  ];
1015
  break;
@@ -1093,11 +1093,7 @@ class iubenda_Settings {
1093
  }
1094
 
1095
  if($section == 'iubenda_cookie_law_solution' && substr( $index, 0, 5 ) === "code_"){
1096
- $parsedCode = iubenda()->parse_configuration(stripslashes_deep($option)) ? iubenda()->parse_configuration(stripslashes_deep($option)) : false;
1097
-
1098
- if(!$parsedCode){
1099
- $this->return_alert($index, $section);
1100
- }
1101
  }
1102
 
1103
  return true;
@@ -1164,12 +1160,105 @@ class iubenda_Settings {
1164
  //get public_id & site_id if only the product key is CS and had a valid embed code
1165
  if ($product_key == 'cs' && $parsed_code = iubenda()->parse_configuration(stripslashes_deep($code))) {
1166
  //getting site id to save it into Iubenda global option
1167
- if (!iub_array_get($result, 'site_id') ?: null) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1168
  $result['site_id'] = iub_array_get($parsed_code, 'siteId');
1169
  }
1170
 
1171
  //getting public id to save it into Iubenda global option by lang
1172
- $result['public_ids'][$lang_id] = (iub_array_get($parsed_code, 'cookiePolicyId') ?: null);
 
 
1173
  }
1174
 
1175
  if (in_array($product_key, ['pp', 'tc'])) {
@@ -1232,7 +1321,26 @@ class iubenda_Settings {
1232
  iubenda()->options[$product_key] = array_merge(iubenda()->options[$product_key] ?: [], $product_option);
1233
  }
1234
 
1235
- update_option( 'iubenda_activated_products', iub_array_get($result, 'iubenda_activated_products', []) ?: [] );
1236
- update_option( 'iubenda_global_options', ['site_id' => iub_array_get($result, 'site_id', '') ?: '', 'public_ids' => iub_array_get($result, 'public_ids', []) ?: []] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1237
  }
1238
  }
1009
 
1010
  $cs_settings = [
1011
  ['label' => __('Style', 'iubenda'), 'value' => $style],
1012
+ ['label' => __('Position', 'iubenda'), 'value' => ucwords(iub_array_get($banner, 'position', 'full-top'))],
1013
  ['label' => __('legislation', 'iubenda'), 'value' => $legislation],
1014
  ];
1015
  break;
1093
  }
1094
 
1095
  if($section == 'iubenda_cookie_law_solution' && substr( $index, 0, 5 ) === "code_"){
1096
+ return !empty($option);
 
 
 
 
1097
  }
1098
 
1099
  return true;
1160
  //get public_id & site_id if only the product key is CS and had a valid embed code
1161
  if ($product_key == 'cs' && $parsed_code = iubenda()->parse_configuration(stripslashes_deep($code))) {
1162
  //getting site id to save it into Iubenda global option
1163
+ if (iub_array_get($parsed_code, 'siteId') ?: null) {
1164
+ $result['site_id'] = iub_array_get($parsed_code, 'siteId');
1165
+ }
1166
+
1167
+ //getting public id to save it into Iubenda global option by lang
1168
+ if (iub_array_get($parsed_code, 'cookiePolicyId') ?: null) {
1169
+ $result['public_ids'][$lang_id] = iub_array_get($parsed_code, 'cookiePolicyId');
1170
+ }
1171
+ }
1172
+
1173
+ if (in_array($product_key, ['pp', 'tc'])) {
1174
+ $parsed_code = iubenda()->parse_tc_pp_configuration(stripslashes_deep($code));
1175
+
1176
+ //getting public id to save it into Iubenda global option lang
1177
+ if ($parsed_code) {
1178
+ $result['public_ids'][$lang_id] = iub_array_get($parsed_code, 'cookie_policy_id');
1179
+ $product_option['button_style'] = iub_array_get($parsed_code, 'button_style');
1180
+ }
1181
+
1182
+ //to make tc/pp button appear in footer by default
1183
+ $product_option['button_position'] = 'automatic';
1184
+
1185
+ // Add a widget in the sidebar
1186
+ do_action('iubenda_assign_widget_to_first_sidebar');
1187
+ }
1188
+
1189
+ $product_option["code_{$lang_id}"] = stripslashes($code);
1190
+ $product_option["manual_code_{$lang_id}"] = stripslashes($code);
1191
+ }
1192
+ }
1193
+
1194
+
1195
+ if (in_array($product_key, ['pp', 'tc'])) {
1196
+ // Add a widget in the sidebar if the button is positioned automatically
1197
+ do_action('iubenda_assign_widget_to_first_sidebar');
1198
+ }
1199
+
1200
+ //add version if Iubenda privacy policy solution activated
1201
+ if ($product_key == 'pp') {
1202
+ $product_option["version"] = 'Manual';
1203
+ }
1204
+
1205
+ // Send options to save it
1206
+ $result['products_option'][$product_key] = $product_option;
1207
+ }else{
1208
+ $result['iubenda_activated_products'][$product_name] = 'false';
1209
+ }
1210
+ }
1211
+
1212
+ return $result;
1213
+ }
1214
+
1215
+
1216
+ /**
1217
+ * @param $products
1218
+ * @param $data
1219
+ * @return array
1220
+ */
1221
+ public function init_prepare_product_options_while_upgrading($products, $data)
1222
+ {
1223
+ $result = [];
1224
+
1225
+ foreach ($products as $product_name => $product_key) {
1226
+ $product_option = [];
1227
+
1228
+ if(iub_array_get($data, "{$product_name}_status") && iub_array_get($data, "{$product_name}_status") == 'true'){
1229
+ $result['iubenda_activated_products'][$product_name] = 'true';
1230
+ $product_option['configured'] = 'true';
1231
+
1232
+ // Check if product is CONS
1233
+ if ($product_key == 'cons') {
1234
+ // iubenda_consent_solution saving data
1235
+ if(iub_array_get($data, "{$product_name}.public_api_key") ?: null){
1236
+ $product_option = ['public_api_key' => iub_array_get($data, "{$product_name}.public_api_key")];
1237
+ }else{
1238
+ $result['iubenda_activated_products'][$product_name] = 'false';
1239
+ }
1240
+ }
1241
+
1242
+ // Check if product in ['PP', 'CS', 'TC'] to check and validate embed codes
1243
+ if (in_array($product_key, ['pp', 'cs', 'tc'])) {
1244
+ $languages = (new ProductHelper())->get_languages();
1245
+ foreach ( $languages as $lang_id => $lang_name ) {
1246
+ $code = iub_array_get($data, "{$product_name}.code_{$lang_id}");
1247
+
1248
+ //check if code is empty or code is invalid
1249
+ $result['codes_statues']["{$product_name}_codes"][] = !empty($code);
1250
+
1251
+ //get public_id & site_id if only the product key is CS and had a valid embed code
1252
+ if ($product_key == 'cs' && $parsed_code = iubenda()->parse_configuration(stripslashes_deep($code))) {
1253
+ //getting site id to save it into Iubenda global option
1254
+ if (iub_array_get($parsed_code, 'siteId') ?: null) {
1255
  $result['site_id'] = iub_array_get($parsed_code, 'siteId');
1256
  }
1257
 
1258
  //getting public id to save it into Iubenda global option by lang
1259
+ if (iub_array_get($parsed_code, 'cookiePolicyId') ?: null) {
1260
+ $result['public_ids'][$lang_id] = iub_array_get($parsed_code, 'cookiePolicyId');
1261
+ }
1262
  }
1263
 
1264
  if (in_array($product_key, ['pp', 'tc'])) {
1321
  iubenda()->options[$product_key] = array_merge(iubenda()->options[$product_key] ?: [], $product_option);
1322
  }
1323
 
1324
+ // Merging old iubenda activated products with new
1325
+ $old_iubenda_activated_products = iub_array_get(iubenda()->options, 'activated_products', []) ?: [];
1326
+ $new_iubenda_activated_products = iub_array_get($result, 'iubenda_activated_products', []) ?: [];
1327
+ update_option( 'iubenda_activated_products', array_merge($old_iubenda_activated_products, $new_iubenda_activated_products));
1328
+
1329
+ // Update Iubenda instance with new activated products
1330
+ iubenda()->options['activated_products'] = array_merge($old_iubenda_activated_products, $new_iubenda_activated_products);
1331
+
1332
+ // Merging old iubenda global options with new
1333
+ $old_iubenda_global_options = iub_array_get(iubenda()->options, 'global_options', []) ?: [];
1334
+
1335
+ $new_iubenda_global_options = [];
1336
+ if(iub_array_get($result, 'site_id') ?: null){
1337
+ $new_iubenda_global_options['site_id'] = iub_array_get($result, 'site_id');
1338
+ }
1339
+ if(iub_array_get($result, 'public_ids', []) ?: null){
1340
+ $new_iubenda_global_options['public_ids'] = iub_array_get($result, 'public_ids', []);
1341
+ }
1342
+ update_option( 'iubenda_global_options', array_merge($old_iubenda_global_options, $new_iubenda_global_options));
1343
+
1344
+ $this->load_defaults();
1345
  }
1346
  }
iubenda_cookie_solution.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Cookie and Consent Solution for the GDPR & ePrivacy
4
  Plugin URI: https://www.iubenda.com
5
  Description: An All-in-One approach developed by iubenda, which includes functionalities of two powerful solutions that help to make your website GDPR and ePrivacy compliant.
6
- Version: 3.0.3
7
  Author: iubenda
8
  Author URI: https://www.iubenda.com
9
  License: MIT License
@@ -34,7 +34,7 @@ define( 'IUB_DEBUG', false );
34
  * @property-read iubenda_Settings $settings
35
  *
36
  * @class iubenda
37
- * @version 3.0.3
38
  */
39
  class iubenda {
40
 
@@ -92,7 +92,7 @@ class iubenda {
92
  )
93
  );
94
  public $base_url;
95
- public $version = '3.0.3';
96
  public $activation = array(
97
  'update_version' => 0,
98
  'update_notice' => true,
@@ -802,7 +802,7 @@ class iubenda {
802
  update_option( 'iubenda_cookie_law_version', $this->version, 'no' );
803
 
804
  // Version 3.0.0 and above
805
- if ( version_compare( $db_version, '3.0.2', '<' ) ) {
806
  $this->upgrading_to_ver_3_process();
807
  }
808
  }
@@ -1100,7 +1100,7 @@ class iubenda {
1100
  'iubenda_consent_solution' => iubenda()->options['cons'],
1101
  'iubenda_consent_solution_status' => 'true',
1102
  ];
1103
- $result = $this->settings->init_prepare_product_options($products, $old_data);
1104
 
1105
  // Count valid codes for iubenda cookie law solution codes and set the service inactive
1106
  if(count(array_filter(iub_array_get($result, "codes_statues.iubenda_cookie_law_solution_codes", []) ?: [])) == 0){
3
  Plugin Name: Cookie and Consent Solution for the GDPR & ePrivacy
4
  Plugin URI: https://www.iubenda.com
5
  Description: An All-in-One approach developed by iubenda, which includes functionalities of two powerful solutions that help to make your website GDPR and ePrivacy compliant.
6
+ Version: 3.0.4
7
  Author: iubenda
8
  Author URI: https://www.iubenda.com
9
  License: MIT License
34
  * @property-read iubenda_Settings $settings
35
  *
36
  * @class iubenda
37
+ * @version 3.0.4
38
  */
39
  class iubenda {
40
 
92
  )
93
  );
94
  public $base_url;
95
+ public $version = '3.0.4';
96
  public $activation = array(
97
  'update_version' => 0,
98
  'update_notice' => true,
802
  update_option( 'iubenda_cookie_law_version', $this->version, 'no' );
803
 
804
  // Version 3.0.0 and above
805
+ if ( version_compare( $db_version, '3.0.4', '<' ) ) {
806
  $this->upgrading_to_ver_3_process();
807
  }
808
  }
1100
  'iubenda_consent_solution' => iubenda()->options['cons'],
1101
  'iubenda_consent_solution_status' => 'true',
1102
  ];
1103
+ $result = $this->settings->init_prepare_product_options_while_upgrading($products, $old_data);
1104
 
1105
  // Count valid codes for iubenda cookie law solution codes and set the service inactive
1106
  if(count(array_filter(iub_array_get($result, "codes_statues.iubenda_cookie_law_solution_codes", []) ?: [])) == 0){
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: cookie banner, cookie law, eprivacy, gdpr, ukgdpr, ccpa, caloppa, lgpd, ds
5
  Requires at least: 5.0
6
  Requires PHP: 7.0.0
7
  Tested up to: 5.9
8
- Stable tag: 3.0.3
9
  License: MIT License
10
  License URI: http://opensource.org/licenses/MIT
11
 
@@ -242,6 +242,10 @@ The Brazilian General Data Protection Law, the ***Lei Geral de Proteção de Dad
242
 
243
  == Changelog ==
244
 
 
 
 
 
245
  = 3.0.3 =
246
  * Tweak: Prefix array_get with iub_ to avoid break comptability with other plugins
247
 
@@ -656,5 +660,6 @@ The Brazilian General Data Protection Law, the ***Lei Geral de Proteção de Dad
656
 
657
  == Upgrade Notice ==
658
 
659
- = 3.0.3 =
660
- * Tweak: Prefix array_get with iub_ to avoid break comptability with other plugins
 
5
  Requires at least: 5.0
6
  Requires PHP: 7.0.0
7
  Tested up to: 5.9
8
+ Stable tag: 3.0.4
9
  License: MIT License
10
  License URI: http://opensource.org/licenses/MIT
11
 
242
 
243
  == Changelog ==
244
 
245
+ = 3.0.4 =
246
+ * Bugfix: Stop parsing code in Cookie banner
247
+ * Bugfix: Errors on plugin update
248
+
249
  = 3.0.3 =
250
  * Tweak: Prefix array_get with iub_ to avoid break comptability with other plugins
251
 
660
 
661
  == Upgrade Notice ==
662
 
663
+ = 3.0.4 =
664
+ * Bugfix: Stop parsing code in Cookie banner
665
+ * Bugfix: Errors on plugin update
views/partials/product-card.php CHANGED
@@ -11,10 +11,14 @@
11
  <h3 class="text-regular text-bold text-gray m-0"><?php echo $serviceOptions['label']; ?></h3>
12
  </div>
13
 
14
- <?php if(isset($serviceOptions['settings'])): ?>
 
 
 
 
15
  <ul id="configiration-iubenda-<?php echo $serviceKey ?>" class="service-on text-gray text-xs " <?php echo $serviceOptions['status']!='true' ? 'style="display: none;"':''; ?> id="toggleServiceOn">
16
  <?php
17
- foreach (iub_array_get($serviceOptions, 'settings') as $setting) {
18
  $value = '';
19
  if ($setting['label'] === 'Version') {
20
  continue;
@@ -29,7 +33,7 @@
29
  }
30
  ?>
31
  <li class="mr-3"><span class="text-bold"><?php echo ucfirst($setting['label']); ?>:</span> <?php echo ucfirst($value); ?></li>
32
- <?php } ?>
33
  </ul>
34
  <?php endif; ?>
35
 
11
  <h3 class="text-regular text-bold text-gray m-0"><?php echo $serviceOptions['label']; ?></h3>
12
  </div>
13
 
14
+ <?php
15
+ //Check if the site_id is not entered before
16
+ $site_id = iub_array_get(iubenda()->options['global_options'], 'site_id') ?: null;
17
+ if(isset($serviceOptions['settings']) && $site_id):
18
+ ?>
19
  <ul id="configiration-iubenda-<?php echo $serviceKey ?>" class="service-on text-gray text-xs " <?php echo $serviceOptions['status']!='true' ? 'style="display: none;"':''; ?> id="toggleServiceOn">
20
  <?php
21
+ foreach (iub_array_get($serviceOptions, 'settings', []) ?: [] as $setting) :
22
  $value = '';
23
  if ($setting['label'] === 'Version') {
24
  continue;
33
  }
34
  ?>
35
  <li class="mr-3"><span class="text-bold"><?php echo ucfirst($setting['label']); ?>:</span> <?php echo ucfirst($value); ?></li>
36
+ <?php endforeach; ?>
37
  </ul>
38
  <?php endif; ?>
39