iubenda Cookie Solution for GDPR - Version 2.1.0-beta

Version Description

  • New: Per-purpose script blocking support
  • New: "Reject" button support
Download this release

Release Info

Developer dfactory
Plugin Icon 128x128 iubenda Cookie Solution for GDPR
Version 2.1.0-beta
Comparing to
See all releases

Code changes from version 2.0.2 to 2.1.0-beta

css/admin.css CHANGED
@@ -62,9 +62,18 @@
62
  #iubenda-tabs .help-tab-content {
63
  margin-right: 0;
64
  }
65
- #iubenda-tabs .help-tab-content textarea {
66
- margin-top: 18px;
67
- width: 100%;
 
 
 
 
 
 
 
 
 
68
  }
69
  #iubenda-tabs .postbox-container .widefat {
70
  border: none;
62
  #iubenda-tabs .help-tab-content {
63
  margin-right: 0;
64
  }
65
+ #iubenda-tabs .help-tab-content .description {
66
+ margin-bottom: 10px;
67
+ }
68
+ #iubenda-tabs .help-tab-content .custom-script-field, #iubenda-tabs .help-tab-content .custom-iframe-field {
69
+ padding-bottom: 10px;
70
+ }
71
+ #iubenda-tabs .help-tab-content .custom-script-field input, #iubenda-tabs .help-tab-content .custom-iframe-field input {
72
+ vertical-align: middle;
73
+ }
74
+ #tab-panel-scripts, #tab-panel-iframes {
75
+ margin-top: 16px;
76
+ margin-bottom: 18px;
77
  }
78
  #iubenda-tabs .postbox-container .widefat {
79
  border: none;
includes/forms.php CHANGED
@@ -339,7 +339,7 @@ class iubenda_Forms {
339
  $args = wp_parse_args( $args, $defaults );
340
 
341
  // sanitize args
342
- $args['ID'] = ! empty( $args['ID'] ) ? (int) $args['ID'] : 0;
343
  $args['status'] = ! empty( $args['status'] ) && in_array( $args['status'], array_keys( $this->statuses ) ) ? $args['status'] : 'publish';
344
  $args['object_type'] = 'post';
345
  $args['object_id'] = ! empty( $args['object_id'] ) ? (int) $args['object_id'] : 0;
@@ -371,8 +371,8 @@ class iubenda_Forms {
371
  if ( ! $args['form_source'] || ! $args['form_fields'] )
372
  return false;
373
 
374
- $post = get_post( (int) $args['ID'] );
375
- $update = ! $post ? false : true;
376
 
377
  // insert new form
378
  if ( ! $update ) {
339
  $args = wp_parse_args( $args, $defaults );
340
 
341
  // sanitize args
342
+ $args['ID'] = ! empty( $args['ID'] ) ? absint( $args['ID'] ) : 0;
343
  $args['status'] = ! empty( $args['status'] ) && in_array( $args['status'], array_keys( $this->statuses ) ) ? $args['status'] : 'publish';
344
  $args['object_type'] = 'post';
345
  $args['object_id'] = ! empty( $args['object_id'] ) ? (int) $args['object_id'] : 0;
371
  if ( ! $args['form_source'] || ! $args['form_fields'] )
372
  return false;
373
 
374
+ $post = $args['ID'] !== 0 ? get_post( $args['ID'] ) : false;
375
+ $update = empty( $post ) ? false : true;
376
 
377
  // insert new form
378
  if ( ! $update ) {
includes/settings.php CHANGED
@@ -22,7 +22,7 @@ class iubenda_Settings {
22
  add_action( 'admin_init', array( $this, 'register_options' ) );
23
  add_action( 'admin_init', array( $this, 'update_plugin' ), 9 );
24
  add_action( 'admin_init', array( $this, 'admin_page_redirect' ), 20 );
25
- add_action( 'admin_init', array( $this, 'process_actions' ) );
26
  add_action( 'admin_menu', array( $this, 'admin_menu_options' ) );
27
  add_action( 'admin_notices', array( $this, 'settings_errors' ) );
28
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
@@ -45,7 +45,7 @@ class iubenda_Settings {
45
  'full_name' => __( 'string', 'iubenda' ),
46
  // 'verified' => __( 'boolean', 'iubenda' ),
47
  );
48
-
49
  $this->legal_notices = array(
50
  'privacy_policy',
51
  'cookie_policy',
@@ -67,6 +67,15 @@ class iubenda_Settings {
67
  )
68
  );
69
 
 
 
 
 
 
 
 
 
 
70
  $links = array(
71
  'en' => array(
72
  'iab' => 'https://www.iubenda.com/en/help/7440-enable-preference-management-iab-framework',
@@ -341,6 +350,15 @@ class iubenda_Settings {
341
  }
342
 
343
  $tab_key = ! empty( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : 'cs';
 
 
 
 
 
 
 
 
 
344
  ?>
345
  <div class="wrap">
346
 
@@ -382,6 +400,25 @@ class iubenda_Settings {
382
  </div>
383
 
384
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
385
  // render custom notices
386
  $this->print_notices();
387
  ?>
@@ -514,18 +551,63 @@ class iubenda_Settings {
514
  </div>
515
  <div id="contextual-help-tabs-wrap-2" class="contextual-help-tabs-wrap">
516
  <div id="tab-panel-scripts" class="help-tab-content active">
517
- <textarea name="iubenda_cookie_law_solution[custom_scripts]" class="large-text" cols="50" rows="10">' . esc_textarea( implode( "\n", iubenda()->options['cs']['custom_scripts'] ) ) . '</textarea>
518
- <p class="description">' . __( 'Enter the list of custom scripts you’d like to block here (one per line)', 'iubenda' ) . '</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
519
  </div>
520
  <div id="tab-panel-iframes" class="help-tab-content">
521
- <textarea name="iubenda_cookie_law_solution[custom_iframes]" class="large-text" cols="50" rows="10">' . esc_textarea( implode( "\n", iubenda()->options['cs']['custom_iframes'] ) ) . '</textarea>
522
- <p class="description">' . __( 'Enter the list of custom iframes you’d like to block here (one per line). ', 'iubenda' ) . '</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
523
  </div>
524
  </div>
525
  </div>
526
  </div>';
527
  }
528
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
529
  /**
530
  * Parsing option.
531
  *
@@ -544,7 +626,7 @@ class iubenda_Settings {
544
  </div>
545
  <div>
546
  <label><input id="iub_skip_parsing" type="checkbox" name="iubenda_cookie_law_solution[skip_parsing]" value="1" ' . checked( true, (bool) iubenda()->options['cs']['skip_parsing'], false ) . '/>' . __( 'Leave scripts untouched on the page if the user has already given consent', 'iubenda' ) . '</label>
547
- <p class="description">(' . __( "improves performance, highly recommended, to be deactivated only if your site uses a caching system", 'iubenda' ) . ')</p>
548
  </div>
549
  </div>
550
  </div>';
@@ -1043,24 +1125,38 @@ class iubenda_Settings {
1043
  $input['code_default'] = ! empty( $input['code_default'] ) ? iubenda()->parse_code( $input['code_default'] ) : '';
1044
 
1045
  // scripts
1046
- if ( isset( $input['custom_scripts'] ) ) {
1047
- $input['custom_scripts'] = trim( $input['custom_scripts'] );
1048
 
1049
- if ( ! empty( $input['custom_scripts'] ) )
1050
- $input['custom_scripts'] = array_map( 'trim', explode( "\n", str_replace( "\r", '', $input['custom_scripts'] ) ) );
1051
- else
1052
- $input['custom_scripts'] = array();
 
 
 
 
 
 
 
1053
  } else
1054
  $input['custom_scripts'] = array();
1055
 
1056
  // iframes
1057
- if ( isset( $input['custom_iframes'] ) ) {
1058
- $input['custom_iframes'] = trim( $input['custom_iframes'] );
1059
 
1060
- if ( ! empty( $input['custom_iframes'] ) )
1061
- $input['custom_iframes'] = array_map( 'trim', explode( "\n", str_replace( "\r", '', $input['custom_iframes'] ) ) );
1062
- else
1063
- $input['custom_iframes'] = array();
 
 
 
 
 
 
 
1064
  } else
1065
  $input['custom_iframes'] = array();
1066
 
@@ -1119,13 +1215,22 @@ class iubenda_Settings {
1119
 
1120
  if ( ! $page )
1121
  return;
 
 
 
 
 
 
 
 
 
1122
 
1123
  // add comments cookie option notice
1124
  if ( $tab_key != 'cs' && ! empty( iubenda()->options['cons']['public_api_key'] ) ) {
1125
  $cookies_enabled = get_option( 'show_comments_cookies_opt_in' );
1126
 
1127
  if ( ! $cookies_enabled ) {
1128
- iubenda()->settings->add_notice( 'iub_comment_cookies_disabled', sprintf( __( 'Please enable comments cookies opt-in checkbox in the <a href="%s" target="_blank">Discussion settings</a>.', 'iubenda' ), esc_url( admin_url( 'options-discussion.php' ) ) ), 'notice' );
1129
  }
1130
  }
1131
 
@@ -1137,23 +1242,15 @@ class iubenda_Settings {
1137
 
1138
  // new forms notice
1139
  if ( ! empty( $result['new'] ) )
1140
- iubenda()->settings->add_notice( 'iub_autodetect_success', sprintf( _n( '%d form detected successfully.', '%d forms detected successfully.', count( $result['new'] ), 'iubenda' ), $result ), 'success' );
1141
 
1142
  // forms changed notice
1143
  if ( ! empty( $result['updated'] ) )
1144
- iubenda()->settings->add_notice( 'iub_autodetect_success', sprintf( _n( '%d form change detected.', '%d form changes detected.', count( $result['updated'] ), 'iubenda' ), $result ), 'success' );
1145
 
1146
  // no changes notice
1147
  if ( empty( $result['new'] ) && empty( $result['updated'] ) )
1148
- iubenda()->settings->add_notice( 'iub_autodetect_success', __( 'No forms or form changes detected.', 'iubenda' ), 'error' );
1149
-
1150
- if ( iubenda()->options['cs']['menu_position'] === 'submenu' && $pagenow === 'admin.php' ) {
1151
- // sub menu
1152
- $redirect_to = admin_url( 'options-general.php?page=iubenda&tab=cons' );
1153
- } else {
1154
- // top menu
1155
- $redirect_to = admin_url( 'admin.php?page=iubenda&tab=cons' );
1156
- }
1157
 
1158
  // make sure it's current host location
1159
  wp_safe_redirect( $redirect_to );
@@ -1213,7 +1310,7 @@ class iubenda_Settings {
1213
 
1214
  // bail if empty fields
1215
  if ( empty( $subject ) || empty( $preferences ) ) {
1216
- iubenda()->settings->add_notice( 'iub_form_fields_missing', __( 'Form saving failed. Please fill the Subject and Preferences fields.', 'iubenda' ), 'error' );
1217
  return;
1218
  }
1219
 
@@ -1237,13 +1334,13 @@ class iubenda_Settings {
1237
  if ( $result ) {
1238
  // form save, inform about form status update
1239
  if ( empty( $form->form_subject ) && empty( $form->form_preferences ) ) {
1240
- iubenda()->settings->add_notice( 'iub_form_saved', __( 'Form saved successfully - form status changed to Mapped.', 'iubenda' ), 'success' );
1241
  // form update
1242
  } else {
1243
- iubenda()->settings->add_notice( 'iub_form_updated', __( 'Form updated successfully.', 'iubenda' ), 'success' );
1244
  }
1245
  } else {
1246
- iubenda()->settings->add_notice( 'iub_form_failed', __( 'Form saving failed.', 'iubenda' ), 'error' );
1247
  }
1248
 
1249
  break;
@@ -1260,15 +1357,30 @@ class iubenda_Settings {
1260
  $result = iubenda()->forms->delete_form( $id );
1261
 
1262
  if ( $result )
1263
- iubenda()->settings->add_notice( 'iub_form_deleted', __( 'Form deleted successfully.', 'iubenda' ), 'success' );
1264
  else
1265
- iubenda()->settings->add_notice( 'iub_form_delete_failed', __( 'Form delete failed.', 'iubenda' ), 'error' );
1266
-
1267
- $redirect_to = admin_url( 'admin.php?page=iubenda&tab=cons' );
1268
 
1269
  // make sure it's current host location
1270
  wp_safe_redirect( $redirect_to );
1271
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1272
  break;
1273
 
1274
  default :
22
  add_action( 'admin_init', array( $this, 'register_options' ) );
23
  add_action( 'admin_init', array( $this, 'update_plugin' ), 9 );
24
  add_action( 'admin_init', array( $this, 'admin_page_redirect' ), 20 );
25
+ add_action( 'admin_init', array( $this, 'process_actions' ), 20 );
26
  add_action( 'admin_menu', array( $this, 'admin_menu_options' ) );
27
  add_action( 'admin_notices', array( $this, 'settings_errors' ) );
28
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
45
  'full_name' => __( 'string', 'iubenda' ),
46
  // 'verified' => __( 'boolean', 'iubenda' ),
47
  );
48
+
49
  $this->legal_notices = array(
50
  'privacy_policy',
51
  'cookie_policy',
67
  )
68
  );
69
 
70
+ $this->tag_types = array(
71
+ 0 => __( 'Not set', 'iubenda' ),
72
+ 1 => __( 'Strictly necessary', 'iubenda' ),
73
+ 2 => __( 'Basic interactions & functionalities', 'iubenda' ),
74
+ 3 => __( 'Experience enhancement', 'iubenda' ),
75
+ 4 => __( 'Analytics', 'iubenda' ),
76
+ 5 => __( 'Targeting & Advertising', 'iubenda' )
77
+ );
78
+
79
  $links = array(
80
  'en' => array(
81
  'iab' => 'https://www.iubenda.com/en/help/7440-enable-preference-management-iab-framework',
350
  }
351
 
352
  $tab_key = ! empty( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : 'cs';
353
+
354
+ // get redirect url
355
+ if ( iubenda()->options['cs']['menu_position'] === 'submenu' && $pagenow === 'admin.php' ) {
356
+ // sub menu
357
+ $redirect_to = admin_url( 'options-general.php?page=iubenda&tab=' . $tab_key );
358
+ } else {
359
+ // top menu
360
+ $redirect_to = admin_url( 'admin.php?page=iubenda&tab=' . $tab_key );
361
+ }
362
  ?>
363
  <div class="wrap">
364
 
400
  </div>
401
 
402
  <?php
403
+ // add per-purpose notice
404
+ if ( $tab_key === 'cs' && iubenda()->options['cs']['skip_parsing'] ) {
405
+ $iubenda_code = '';
406
+
407
+ if ( iubenda()->multilang === true && defined( 'ICL_LANGUAGE_CODE' ) && isset( iubenda()->options['cs']['code_' . ICL_LANGUAGE_CODE] ) ) {
408
+ $iubenda_code = iubenda()->options['cs']['code_' . ICL_LANGUAGE_CODE];
409
+
410
+ // no code for current language, use default
411
+ if ( ! $iubenda_code )
412
+ $iubenda_code = iubenda()->options['cs']['code_default'];
413
+ } else
414
+ $iubenda_code = iubenda()->options['cs']['code_default'];
415
+
416
+ $per_purpose_enabled = preg_match( '/\"perPurposeConsent\"\: *\"true\"/', $iubenda_code );
417
+
418
+ if ( $per_purpose_enabled )
419
+ $this->add_notice( 'iub_per_purpose_enabled', sprintf( __( 'If you are using per-purpose script blocking please disable the "Leave scripts untouched on the page if the user has already given consent" option. <a href="%s" target="_self">Disable now</a>', 'iubenda' ), esc_url( add_query_arg( 'action', 'disable_skip_parsing', $redirect_to ) ) ), 'notice' );
420
+ }
421
+
422
  // render custom notices
423
  $this->print_notices();
424
  ?>
551
  </div>
552
  <div id="contextual-help-tabs-wrap-2" class="contextual-help-tabs-wrap">
553
  <div id="tab-panel-scripts" class="help-tab-content active">
554
+ <p class="description">' . __( 'Provide a list of custom scripts you’d like to block and assign their purpose.', 'iubenda' ) . '</p>
555
+ <div id="custom-script-field-template" class="template-field" style="display: none;">
556
+ <input type="text" class="regular-text" value="" name="iubenda_cookie_law_solution[custom_scripts][script][]" placeholder="' . __( 'Enter custom script', 'iubenda' ) . '" /> ' . $this->render_tag_types( 'script', 0 ) . ' <a href="#" class="remove-custom-script-field button-secondary" title="' . __( 'Remove', 'iubenda' ) . '">-</a>
557
+ </div>';
558
+
559
+ if ( ! empty( iubenda()->options['cs']['custom_scripts'] ) ) {
560
+ foreach ( iubenda()->options['cs']['custom_scripts'] as $script => $type ) {
561
+ echo '
562
+ <div class="custom-script-field">
563
+ <input type="text" class="regular-text" value="' . esc_attr( $script ) . '" name="iubenda_cookie_law_solution[custom_scripts][script][]" placeholder="' . __( 'Enter custom script', 'iubenda' ) . '" /> ' . $this->render_tag_types( 'script', $type ) . ' <a href="#" class="remove-custom-script-field button-secondary" title="' . __( 'Remove', 'iubenda' ) . '">-</a>
564
+ </div>';
565
+ }
566
+ }
567
+
568
+ echo '
569
+ <a href="#" class="add-custom-script-field button-secondary">Add New Script</a>
570
  </div>
571
  <div id="tab-panel-iframes" class="help-tab-content">
572
+ <p class="description">' . __( 'Provide a list of custom iframes you’d like to block and assign their purpose. ', 'iubenda' ) . '</p>
573
+ <div id="custom-iframe-field-template" class="template-field" style="display: none;">
574
+ <input type="text" class="regular-text" value="" name="iubenda_cookie_law_solution[custom_iframes][iframe][]" placeholder="' . __( 'Enter custom iframe', 'iubenda' ) . '" /> ' . $this->render_tag_types( 'iframe', 0 ) . ' <a href="#" class="remove-custom-iframe-field button-secondary" title="' . __( 'Remove', 'iubenda' ) . '">-</a>
575
+ </div>';
576
+
577
+ if ( ! empty( iubenda()->options['cs']['custom_iframes'] ) ) {
578
+ foreach ( iubenda()->options['cs']['custom_iframes'] as $iframe => $type ) {
579
+ echo '
580
+ <div class="custom-iframe-field">
581
+ <input type="text" class="regular-text" value="' . esc_attr( $iframe ) . '" name="iubenda_cookie_law_solution[custom_iframes][iframe][]" placeholder="' . __( 'Enter custom iframe', 'iubenda' ) . '" /> ' . $this->render_tag_types( 'iframe', $type ) . ' <a href="#" class="remove-custom-iframe-field button-secondary" title="' . __( 'Remove', 'iubenda' ) . '">-</a>
582
+ </div>';
583
+ }
584
+ }
585
+
586
+ echo '
587
+ <a href="#" class="add-custom-iframe-field button-secondary">Add New Iframe</a>
588
  </div>
589
  </div>
590
  </div>
591
  </div>';
592
  }
593
 
594
+ /**
595
+ * Prepare tag types select.
596
+ *
597
+ * @param string $type
598
+ * @param int $selected
599
+ * @return string
600
+ */
601
+ function render_tag_types( $type, $selected ) {
602
+ $html = '<select name="iubenda_cookie_law_solution[custom_' . $type . 's][type][]">';
603
+
604
+ foreach ( $this->tag_types as $tag_id => $tag_name ) {
605
+ $html .= '<option value="' . esc_attr( $tag_id ) . '" ' . selected( $selected, $tag_id, false ) . '>' . esc_html( $tag_name ) . '</option>';
606
+ }
607
+
608
+ return $html . '</select>';
609
+ }
610
+
611
  /**
612
  * Parsing option.
613
  *
626
  </div>
627
  <div>
628
  <label><input id="iub_skip_parsing" type="checkbox" name="iubenda_cookie_law_solution[skip_parsing]" value="1" ' . checked( true, (bool) iubenda()->options['cs']['skip_parsing'], false ) . '/>' . __( 'Leave scripts untouched on the page if the user has already given consent', 'iubenda' ) . '</label>
629
+ <p class="description">(' . __( "improves performance, highly recommended, to be deactivated only if your site uses a caching system or you have per-purpose script blokcing active.", 'iubenda' ) . ')</p>
630
  </div>
631
  </div>
632
  </div>';
1125
  $input['code_default'] = ! empty( $input['code_default'] ) ? iubenda()->parse_code( $input['code_default'] ) : '';
1126
 
1127
  // scripts
1128
+ if ( ! empty( $input['custom_scripts'] ) && ! empty( $input['custom_scripts']['script'] ) && ! empty( $input['custom_scripts']['type'] ) ) {
1129
+ $scripts = array();
1130
 
1131
+ // first field is template
1132
+ if ( count( $input['custom_scripts']['script'] ) > 1 ) {
1133
+ foreach ( $input['custom_scripts']['script'] as $number => $script ) {
1134
+ $trimmed = trim( $script );
1135
+
1136
+ if ( $trimmed !== '' )
1137
+ $scripts[$trimmed] = (int) $input['custom_scripts']['type'][$number];
1138
+ }
1139
+ }
1140
+
1141
+ $input['custom_scripts'] = $scripts;
1142
  } else
1143
  $input['custom_scripts'] = array();
1144
 
1145
  // iframes
1146
+ if ( ! empty( $input['custom_iframes'] ) && ! empty( $input['custom_iframes']['iframe'] ) && ! empty( $input['custom_iframes']['type'] ) ) {
1147
+ $iframes = array();
1148
 
1149
+ // first field is template
1150
+ if ( count( $input['custom_iframes']['iframe'] ) > 1 ) {
1151
+ foreach ( $input['custom_iframes']['iframe'] as $number => $iframe ) {
1152
+ $trimmed = trim( $iframe );
1153
+
1154
+ if ( $trimmed !== '' )
1155
+ $iframes[$trimmed] = (int) $input['custom_iframes']['type'][$number];
1156
+ }
1157
+ }
1158
+
1159
+ $input['custom_iframes'] = $iframes;
1160
  } else
1161
  $input['custom_iframes'] = array();
1162
 
1215
 
1216
  if ( ! $page )
1217
  return;
1218
+
1219
+ // get redirect url
1220
+ if ( iubenda()->options['cs']['menu_position'] === 'submenu' && $pagenow === 'admin.php' ) {
1221
+ // sub menu
1222
+ $redirect_to = admin_url( 'options-general.php?page=iubenda&tab=' . $tab_key );
1223
+ } else {
1224
+ // top menu
1225
+ $redirect_to = admin_url( 'admin.php?page=iubenda&tab=' . $tab_key );
1226
+ }
1227
 
1228
  // add comments cookie option notice
1229
  if ( $tab_key != 'cs' && ! empty( iubenda()->options['cons']['public_api_key'] ) ) {
1230
  $cookies_enabled = get_option( 'show_comments_cookies_opt_in' );
1231
 
1232
  if ( ! $cookies_enabled ) {
1233
+ $this->add_notice( 'iub_comment_cookies_disabled', sprintf( __( 'Please enable comments cookies opt-in checkbox in the <a href="%s" target="_blank">Discussion settings</a>.', 'iubenda' ), esc_url( admin_url( 'options-discussion.php' ) ) ), 'notice' );
1234
  }
1235
  }
1236
 
1242
 
1243
  // new forms notice
1244
  if ( ! empty( $result['new'] ) )
1245
+ $this->add_notice( 'iub_autodetect_success', sprintf( _n( '%d form detected successfully.', '%d forms detected successfully.', count( $result['new'] ), 'iubenda' ), $result ), 'success' );
1246
 
1247
  // forms changed notice
1248
  if ( ! empty( $result['updated'] ) )
1249
+ $this->add_notice( 'iub_autodetect_success', sprintf( _n( '%d form change detected.', '%d form changes detected.', count( $result['updated'] ), 'iubenda' ), $result ), 'success' );
1250
 
1251
  // no changes notice
1252
  if ( empty( $result['new'] ) && empty( $result['updated'] ) )
1253
+ $this->add_notice( 'iub_autodetect_success', __( 'No forms or form changes detected.', 'iubenda' ), 'error' );
 
 
 
 
 
 
 
 
1254
 
1255
  // make sure it's current host location
1256
  wp_safe_redirect( $redirect_to );
1310
 
1311
  // bail if empty fields
1312
  if ( empty( $subject ) || empty( $preferences ) ) {
1313
+ $this->add_notice( 'iub_form_fields_missing', __( 'Form saving failed. Please fill the Subject and Preferences fields.', 'iubenda' ), 'error' );
1314
  return;
1315
  }
1316
 
1334
  if ( $result ) {
1335
  // form save, inform about form status update
1336
  if ( empty( $form->form_subject ) && empty( $form->form_preferences ) ) {
1337
+ $this->add_notice( 'iub_form_saved', __( 'Form saved successfully - form status changed to Mapped.', 'iubenda' ), 'success' );
1338
  // form update
1339
  } else {
1340
+ $this->add_notice( 'iub_form_updated', __( 'Form updated successfully.', 'iubenda' ), 'success' );
1341
  }
1342
  } else {
1343
+ $this->add_notice( 'iub_form_failed', __( 'Form saving failed.', 'iubenda' ), 'error' );
1344
  }
1345
 
1346
  break;
1357
  $result = iubenda()->forms->delete_form( $id );
1358
 
1359
  if ( $result )
1360
+ $this->add_notice( 'iub_form_deleted', __( 'Form deleted successfully.', 'iubenda' ), 'success' );
1361
  else
1362
+ $this->add_notice( 'iub_form_delete_failed', __( 'Form delete failed.', 'iubenda' ), 'error' );
 
 
1363
 
1364
  // make sure it's current host location
1365
  wp_safe_redirect( $redirect_to );
1366
+ exit;
1367
+
1368
+ break;
1369
+
1370
+ case 'disable_skip_parsing' :
1371
+
1372
+ // disable skip parsing option
1373
+ $options = iubenda()->options['cs'];
1374
+ $options['skip_parsing'] = false;
1375
+
1376
+ update_option( 'iubenda_cookie_law_solution', $options );
1377
+
1378
+ $this->add_notice( 'iub_settings_updated', __( 'Settings saved.', 'iubenda' ), 'success' );
1379
+
1380
+ // make sure it's current host location
1381
+ wp_safe_redirect( $redirect_to );
1382
+ exit;
1383
+
1384
  break;
1385
 
1386
  default :
iubenda-cookie-class/README.md CHANGED
@@ -98,6 +98,10 @@ These operations take place in accordance with the rules explained in [this guid
98
 
99
  ## Changelog
100
 
 
 
 
 
101
  ##### 3.4.0
102
  * New: Introducing wildcard support for scripts and iframes
103
 
98
 
99
  ## Changelog
100
 
101
+ ##### 4.0.0
102
+ * New: Per-purpose script blocking support
103
+ * New: Reject button support
104
+
105
  ##### 3.4.0
106
  * New: Introducing wildcard support for scripts and iframes
107
 
iubenda-cookie-class/iubenda.class.php CHANGED
@@ -5,7 +5,7 @@
5
  * @author iubenda s.r.l
6
  * @copyright 2018-2019, iubenda s.r.l
7
  * @license GNU/GPL
8
- * @version 3.4.0
9
  * @deprecated
10
  *
11
  * This program is free software: you can redistribute it and/or modify
@@ -27,115 +27,113 @@ class iubendaParser {
27
  // variables
28
  const IUB_REGEX_PATTERN = '/<!--\s*IUB_COOKIE_POLICY_START\s*-->(.*?)<!--\s*IUB_COOKIE_POLICY_END\s*-->/s';
29
  const IUB_REGEX_PATTERN_2 = '/<!--\s*IUB-COOKIE-BLOCK-START\s*-->(.*?)<!--\s*IUB-COOKIE-BLOCK-END\s*-->/s';
 
30
  const IUB_REGEX_SKIP_PATTERN = '/<!--\s*IUB-COOKIE-BLOCK-SKIP-START\s*-->(.*?)<!--\s*IUB-COOKIE-BLOCK-SKIP-END\s*-->/s';
31
 
32
  // scripts
33
- public $auto_script_tags = array(
34
- // google
35
- 'apis.google.com/js/plusone.js',
36
- 'apis.google.com/js/client/plusone.js',
37
- 'apis.google.com/js/platform.js',
38
- 'apis.google.com/js/api.js', // oauth
39
- 'cse.google.com/cse.js', // site search
40
- 'googlesyndication.com/pagead/js/adsbygoogle.js',
41
- 'googlesyndication.com/pagead/show_ads.js',
42
- 'googleadservices.com/pagead/conversion.js',
43
- 'googletagmanager.com/gtm.js',
44
- 'www.googletagmanager.com/gtag/js',
45
- 'google.com/recaptcha/',
46
- 'www.youtube.com/iframe_api',
47
- 'youtu.be',
48
- 'window.adsbygoogle',
49
- // twitter
50
- 'platform.twitter.com/widgets.js',
51
- 'static.ads-twitter.com',
52
- // facebook
53
- 'connect.facebook.net',
54
- // instagram
55
- 'instawidget.net/js/instawidget.js',
56
- // sharethis
57
- 'sharethis.com/button/buttons.js',
58
- // addthis
59
- 'addthis.com/js/',
60
- // disqus
61
- 'disqus.com/embed.js',
62
- // linkedin
63
- 'platform.linkedin.com/in.js',
64
- // scorecardresearch
65
- 'scorecardresearch.com/beacon.js',
66
- // neodata
67
- 'neodatagroup.com',
68
- // criteo
69
- 'static.criteo.net/js/',
70
- // adagio
71
- 'adagionet.com/uploads/js/sipra.js',
72
- // rainbowtgx
73
- 'cdn-wx.rainbowtgx.com/rtgx.js',
74
- // pinterest
75
- 'pinterest.com/js/pinit.js',
76
- // linkpulse
77
- 'lp4.io',
78
- // optimizely
79
- 'cdn.optimizely.com/js/',
80
- // getsatisfaction
81
- 'loader.engage.gsfn.us/loader.js',
82
- // outbrain
83
- 'outbrain.js',
84
- // headway
85
- 'headwayapp.co/widget.js',
86
- // codepen
87
- 'codepen.io',
88
- // freshchat
89
- 'wchat.freshchat.com',
90
- // uservoice
91
- 'widget.uservoice.com',
92
- 'UserVoice.push',
93
- // adroll
94
- 's.adroll.com',
95
- // olark
96
- 'static.olark.com/jsclient/loader0.js',
97
- // cxense
98
- 'scdn.cxense.com',
99
- // segment
100
- 'cdn.segment.io/analytics.js',
101
- 'cdn.segment.com/analytics.js',
102
- // kissmetrics
103
- 'i.kissmetrics.com/i.js',
104
- // mixpanel
105
- 'cdn.mxpnl.com',
106
- // pingdom
107
- 'rum-static.pingdom.net/prum.min.js',
108
- // bing
109
- 'bat.bing.com',
110
- // elevio
111
- 'cdn.elev.io',
112
- // paypal
113
- 'paypalobjects.com/js/external/api.js', // paypal login
114
- 'paypalobjects.com/api/checkout.js', // paypal checkout
115
- );
116
 
117
  // iframes
118
- public $auto_iframe_tags = array(
119
- // google
120
- 'apis.google.com',
121
- 'maps.google.it/maps',
122
- 'maps.google.com/maps',
123
- 'www.google.com/maps/embed',
124
- 'googletagmanager.com/ns.html',
125
- 'window.adsbygoogle',
126
- // youtube
127
- 'youtube.com',
128
- // twitter
129
- 'platform.twitter.com',
130
- // facebook
131
- 'www.facebook.com/plugins/like.php',
132
- 'www.facebook.com/*/plugins/like.php',
133
- 'www.facebook.com/plugins/likebox.php',
134
- 'www.facebook.com/*/plugins/likebox.php',
135
- // vimeo
136
- 'player.vimeo.com',
137
- // 4w
138
- '4wnet.com'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  );
140
 
141
  private $type = 'page';
@@ -162,16 +160,6 @@ class iubendaParser {
162
  * @param array $args
163
  */
164
  public function __construct( $content_page = '', $args = array() ) {
165
- // check scripts
166
- if ( ! empty( $args['scripts'] ) && is_array( $args['scripts'] ) ) {
167
- $this->auto_script_tags = array_unique( array_merge( $this->auto_script_tags, $args['scripts'] ) );
168
- }
169
-
170
- // check iframes
171
- if ( ! empty( $args['iframes'] ) && is_array( $args['iframes'] ) ) {
172
- $this->auto_iframe_tags = array_unique( array_merge( $this->auto_iframe_tags, $args['iframes'] ) );
173
- }
174
-
175
  // valid type?
176
  $this->type = ! empty( $args['type'] ) && in_array( $args['type'], array( 'page', 'faster' ), true ) ? $args['type'] : 'page';
177
 
@@ -182,6 +170,49 @@ class iubendaParser {
182
  // set content
183
  $this->original_content_page = $content_page;
184
  $this->content_page = $content_page;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  }
186
 
187
  /**
@@ -199,45 +230,123 @@ class iubendaParser {
199
  * @return boolean
200
  */
201
  static function consent_given() {
 
 
202
  foreach ( $_COOKIE as $key => $value ) {
203
- if ( self::strpos_array( $key, array( '_iub_cs-s', '_iub_cs' ) ) )
204
- return true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
205
  }
206
 
207
- return false;
208
  }
209
 
210
  /**
211
- * Static, utility function: strpos for array wilth wildcard support
212
  *
213
- * @param type $haystack
214
- * @param type $needle
215
- * @return boolean
216
  */
217
- static function strpos_array( $haystack, $needle ) {
218
- if ( empty( $haystack ) || empty( $needle ) )
219
- return false;
220
 
221
- $needle = ! is_array( $needle ) ? array( $needle ) : $needle;
222
-
223
- foreach ( $needle as $need ) {
224
- // wildcard?
225
- if ( strpos( $need, '/*/' ) !== false ) {
226
- // strtok - removes query string
227
- // str_replace - removes double slashes // from url
228
- // preg_replace - removes http or https from url
229
- $haystack = strtok( str_replace( '//', '', preg_replace( "(^https?://)", "", $haystack ) ), '?' );
230
-
231
- if ( fnmatch( $need, $haystack ) !== false )
232
- return true;
233
- // regular
234
- } else {
235
- if ( strpos( $haystack, $need ) !== false )
236
- return true;
237
  }
238
  }
239
-
240
- return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
241
  }
242
 
243
  /**
@@ -246,7 +355,7 @@ class iubendaParser {
246
  * @param mixed $content
247
  * @return mixed
248
  */
249
- public function create_tags( $content ) {
250
  $elements = $content->find( "*" );
251
  $js = '';
252
 
@@ -258,6 +367,9 @@ class iubendaParser {
258
 
259
  switch ( $e->tag ) {
260
  case 'script':
 
 
 
261
  $class = $e->class;
262
  $e->class = $class . ' ' . $this->iub_class;
263
  $e->type = 'text/plain';
@@ -265,6 +377,9 @@ class iubendaParser {
265
  break;
266
 
267
  case 'iframe':
 
 
 
268
  $new_src = $this->iub_empty;
269
  $class = $e->class;
270
  $e->suppressedsrc = $e->src;
@@ -274,7 +389,7 @@ class iubendaParser {
274
  break;
275
 
276
  default:
277
- $js = $e->outertext;
278
  break;
279
  }
280
  }
@@ -301,11 +416,6 @@ class iubendaParser {
301
 
302
  switch ( $element->tag ) {
303
  case 'script':
304
- $class = trim( $element->class );
305
- $element->class = ( $class !== '' ? $class . ' ' : '' ) . $this->iub_class_skip;
306
- $js .= $element->outertext;
307
- break;
308
-
309
  case 'iframe':
310
  $class = trim( $element->class );
311
  $element->class = ( $class !== '' ? $class . ' ' : '' ) . $this->iub_class_skip;
@@ -331,15 +441,18 @@ class iubendaParser {
331
  public function parse_scripts() {
332
  switch ( $this->type ) {
333
  case 'page':
334
- $html = str_get_html( $this->content_page, $lowercase = true, $force_tags_closed = true, $strip = false );
 
335
 
336
  if ( is_object( $html ) ) {
 
337
  $scripts = $html->find( 'script' );
338
 
339
  if ( is_array( $scripts ) ) {
340
  $count = count( $scripts );
341
  $class_skip = $this->iub_class_skip;
342
 
 
343
  for ( $j = 0; $j < $count; $j ++ ) {
344
  $s = $scripts[$j];
345
  $script_class = trim( $s->class );
@@ -360,8 +473,10 @@ class iubendaParser {
360
 
361
  if ( ! empty( $s->innertext ) ) {
362
  $this->scripts_inline_detected[] = $s->innertext;
 
 
363
 
364
- if ( self::strpos_array( $s->innertext, $this->auto_script_tags ) !== false ) {
365
  $class = $s->class;
366
  $s->class = $class . ' ' . $this->iub_class_inline;
367
  $s->type = 'text/plain';
@@ -372,11 +487,17 @@ class iubendaParser {
372
 
373
  if ( $src ) {
374
  $this->scripts_detected[] = $src;
 
 
375
 
376
- if ( self::strpos_array( $src, $this->auto_script_tags ) !== false ) {
377
  $class = $s->class;
378
  $s->class = $class . ' ' . $this->iub_class;
379
  $s->type = 'text/plain';
 
 
 
 
380
  $this->scripts_converted[] = $src;
381
  }
382
  }
@@ -523,14 +644,20 @@ class iubendaParser {
523
  // add inline script as detected
524
  if ( ! empty( $script->nodeValue ) )
525
  $this->scripts_inline_detected[] = $script->nodeValue;
 
 
 
526
 
527
- if ( self::strpos_array( $src, $script_tags ) ) {
528
  $script->setAttribute( 'type', 'text/plain' );
529
  $script->setAttribute( 'class', $script->getAttribute( 'class' ) . ' ' . $class );
 
 
 
530
 
531
  // add script as converted
532
  $this->scripts_converted[] = $src;
533
- } elseif ( self::strpos_array( $script->nodeValue, $script_tags ) ) {
534
  $script->setAttribute( 'type', 'text/plain' );
535
  $script->setAttribute( 'class', $script->getAttribute( 'class' ) . ' ' . $class_inline );
536
 
@@ -560,7 +687,7 @@ class iubendaParser {
560
  public function parse_iframes() {
561
  switch ( $this->type ) {
562
  case 'page':
563
- $html = str_get_html( $this->content_page, $lowercase = true, $force_tags_closed = true, $strip = false );
564
 
565
  if ( is_object( $html ) ) {
566
  $iframes = $html->find( 'iframe' );
@@ -587,11 +714,17 @@ class iubendaParser {
587
  $src = $i->src;
588
  $this->iframes_detected[] = $src;
589
 
590
- if ( self::strpos_array( $src, $this->auto_iframe_tags ) !== false ) {
 
 
591
  $class = $i->class;
592
  $i->suppressedsrc = $src;
593
  $i->src = $this->iub_empty;
594
  $i->class = $class . ' ' . $this->iub_class;
 
 
 
 
595
  $this->iframes_converted[] = $src;
596
  }
597
  }
@@ -642,11 +775,16 @@ class iubendaParser {
642
 
643
  // add iframe as detected
644
  $this->iframes_detected[] = $src;
 
 
645
 
646
- if ( self::strpos_array( $src, $iframe_tags ) ) {
647
  $iframe->setAttribute( 'src', $empty );
648
  $iframe->setAttribute( 'suppressedsrc', $src );
649
  $iframe->setAttribute( 'class', $iframe_class . ' ' . $class );
 
 
 
650
 
651
  // add iframe as converted
652
  $this->iframes_converted[] = $src;
@@ -685,7 +823,7 @@ class iubendaParser {
685
  // get HTML dom from string
686
  $html = str_get_html( $scripts[1][$j], true, true, false );
687
 
688
- // skip scripts and iframes inside IUBENDAs comments
689
  $js_scripts[] = $this->skip_tags( $html );
690
  }
691
 
@@ -696,26 +834,40 @@ class iubendaParser {
696
  unset( $scripts );
697
 
698
  // block
699
- foreach ( array( 'IUB_REGEX_PATTERN', 'IUB_REGEX_PATTERN_2' ) as $pattern ) {
700
  preg_match_all( constant( 'self::' . $pattern ), $this->content_page, $scripts );
701
 
 
 
 
 
 
 
 
 
 
 
 
702
  // found any content?
703
- if ( is_array( $scripts[1] ) ) {
704
- $count = count( $scripts[1] );
705
  $js_scripts = array();
706
 
707
  for ( $j = 0; $j < $count; $j++ ) {
708
- $this->iub_comments_detected[] = $scripts[1][$j];
709
 
710
  // get HTML dom from string
711
- $html = str_get_html( $scripts[1][$j], $lowercase = true, $force_tags_closed = true, $strip = false );
 
 
 
712
 
713
  // convert scripts, iframes and other code inside IUBENDAs comment in text/plain to not generate cookies
714
- $js_scripts[] = $this->create_tags( $html );
715
  }
716
 
717
- if ( ( is_array( $scripts[1] ) && is_array( $js_scripts ) ) && ( $count >= 1 && count( $js_scripts ) >= 1 ) )
718
- $this->content_page = strtr( $this->content_page, array_combine( $scripts[1], $js_scripts ) );
719
  }
720
  }
721
  }
@@ -753,16 +905,88 @@ class iubendaParser {
753
  <script>
754
  var iCallback = function(){};
755
 
756
- if ('callback' in _iub.csConfiguration) {
757
- if ('onConsentGiven' in _iub.csConfiguration.callback)
758
  iCallback = _iub.csConfiguration.callback.onConsentGiven;
759
 
760
  _iub.csConfiguration.callback.onConsentGiven = function() {
761
  iCallback();
762
 
763
- jQuery('noscript._no_script_iub').each(function (a, b) { var el = jQuery(b); el.after(el.html()); });
764
  };
765
  };
766
  </script>";
767
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
768
  }
5
  * @author iubenda s.r.l
6
  * @copyright 2018-2019, iubenda s.r.l
7
  * @license GNU/GPL
8
+ * @version 4.0.0
9
  * @deprecated
10
  *
11
  * This program is free software: you can redistribute it and/or modify
27
  // variables
28
  const IUB_REGEX_PATTERN = '/<!--\s*IUB_COOKIE_POLICY_START\s*-->(.*?)<!--\s*IUB_COOKIE_POLICY_END\s*-->/s';
29
  const IUB_REGEX_PATTERN_2 = '/<!--\s*IUB-COOKIE-BLOCK-START\s*-->(.*?)<!--\s*IUB-COOKIE-BLOCK-END\s*-->/s';
30
+ const IUB_REGEX_PURPOSE_PATTERN = '/<!--\s*IUB-COOKIE-BLOCK-START-PURPOSE-(\d+)\s*-->(.*?)<!--\s*IUB-COOKIE-BLOCK-END-PURPOSE-\d+\s*-->/s';
31
  const IUB_REGEX_SKIP_PATTERN = '/<!--\s*IUB-COOKIE-BLOCK-SKIP-START\s*-->(.*?)<!--\s*IUB-COOKIE-BLOCK-SKIP-END\s*-->/s';
32
 
33
  // scripts
34
+ public $auto_script_tags = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
  // iframes
37
+ public $auto_iframe_tags = array();
38
+
39
+ // purposes
40
+ public $purposes = array();
41
+
42
+ // per-purpose scripts
43
+ public $script_tags = array(
44
+ // Strictly necessary
45
+ 1 => array(),
46
+ // Basic interactions & functionalities
47
+ 2 => array(
48
+ 'apis.google.com/js/api.js',
49
+ 'cse.google.com/cse.js',
50
+ 'googletagmanager.com/gtm.js',
51
+ 'loader.engage.gsfn.us/loader.js',
52
+ 'headwayapp.co/widget.js',
53
+ 'wchat.freshchat.com',
54
+ 'widget.uservoice.com',
55
+ 'UserVoice.push',
56
+ 'static.olark.com/jsclient/loader0.js',
57
+ 'cdn.elev.io',
58
+ 'paypalobjects.com/js/external/api.js',
59
+ 'paypalobjects.com/api/checkout.js'
60
+ ),
61
+ // Experience enhancement
62
+ 3 => array(
63
+ 'apis.google.com/js/plusone.js',
64
+ 'apis.google.com/js/client/plusone.js',
65
+ 'apis.google.com/js/platform.js',
66
+ 'www.youtube.com/iframe_api',
67
+ 'youtu.be',
68
+ 'platform.twitter.com/widgets.js',
69
+ 'instawidget.net/js/instawidget.js',
70
+ 'disqus.com/embed.js',
71
+ 'platform.linkedin.com/in.js',
72
+ 'pinterest.com/js/pinit.js',
73
+ 'codepen.io',
74
+ 'bat.bing.com'
75
+ ),
76
+ // Analytics
77
+ 4 => array(
78
+ 'sharethis.com/button/buttons.js',
79
+ 'addthis.com/js/',
80
+ 'scorecardresearch.com/beacon.js',
81
+ 'neodatagroup.com',
82
+ 'lp4.io',
83
+ 'cdn.optimizely.com/js/',
84
+ 'cdn.segment.io/analytics.js',
85
+ 'cdn.segment.com/analytics.js',
86
+ 'i.kissmetrics.com/i.js',
87
+ 'cdn.mxpnl.com',
88
+ 'rum-static.pingdom.net/prum.min.js'
89
+ ),
90
+ // Targeting & Advertising
91
+ 5 => array(
92
+ 'googlesyndication.com/pagead/js/adsbygoogle.js',
93
+ 'googlesyndication.com/pagead/show_ads.js',
94
+ 'googleadservices.com/pagead/conversion.js',
95
+ 'www.googletagmanager.com/gtag/js',
96
+ 'window.adsbygoogle',
97
+ 'static.ads-twitter.com',
98
+ 'connect.facebook.net',
99
+ 'static.criteo.net/js/',
100
+ 'adagionet.com/uploads/js/sipra.js',
101
+ 'cdn-wx.rainbowtgx.com/rtgx.js',
102
+ 'outbrain.js',
103
+ 's.adroll.com',
104
+ 'scdn.cxense.com'
105
+ )
106
+ );
107
+
108
+ // per-purpose iframes
109
+ public $iframe_tags = array(
110
+ // Strictly necessary
111
+ 1 => array(),
112
+ // Basic interactions & functionalities
113
+ 2 => array(
114
+ 'googletagmanager.com/ns.html'
115
+ ),
116
+ // Experience enhancement
117
+ 3 => array(
118
+ 'apis.google.com',
119
+ 'maps.google.it/maps',
120
+ 'maps.google.com/maps',
121
+ 'www.google.com/maps/embed',
122
+ 'youtube.com',
123
+ 'platform.twitter.com',
124
+ 'player.vimeo.com',
125
+ 'www.facebook.com/plugins/like.php',
126
+ 'www.facebook.com/*/plugins/like.php',
127
+ 'www.facebook.com/plugins/likebox.php',
128
+ 'www.facebook.com/*/plugins/likebox.php'
129
+ ),
130
+ // Analytics
131
+ 4 => array(),
132
+ // Targeting & Advertising
133
+ 5 => array(
134
+ 'window.adsbygoogle',
135
+ '4wnet.com'
136
+ )
137
  );
138
 
139
  private $type = 'page';
160
  * @param array $args
161
  */
162
  public function __construct( $content_page = '', $args = array() ) {
 
 
 
 
 
 
 
 
 
 
163
  // valid type?
164
  $this->type = ! empty( $args['type'] ) && in_array( $args['type'], array( 'page', 'faster' ), true ) ? $args['type'] : 'page';
165
 
170
  // set content
171
  $this->original_content_page = $content_page;
172
  $this->content_page = $content_page;
173
+
174
+ // get purposes
175
+ $this->purposes = self::get_purposes();
176
+
177
+ // check for additional scripts
178
+ if ( ! empty( $args['scripts'] ) && is_array( $args['scripts'] ) ) {
179
+ // array is not multidimensional, backward compatibility, so block it
180
+ if ( ! is_array( reset( $args['scripts'] ) ) ) {
181
+ $this->auto_script_tags = array_merge( $this->auto_script_tags, $args['scripts'] );
182
+ // array is multidimensional, assign per purpose
183
+ } else {
184
+ // block unassigned script
185
+ if ( array_key_exists( 0, $args['scripts'] ) ) {
186
+ $this->auto_script_tags = array_merge( $this->auto_script_tags, $args['scripts'][0] );
187
+ unset( $args['scripts'][0] );
188
+ }
189
+
190
+ $this->script_tags = $this->array_merge_custom( $this->script_tags, $args['scripts'] );
191
+ }
192
+ }
193
+
194
+ // check for additional iframes
195
+ if ( ! empty( $args['iframes'] ) && is_array( $args['iframes'] ) ) {
196
+ // array is not multidimensional, backward compatibility, so assign block it
197
+ if ( ! is_array( reset( $args['iframes'] ) ) ) {
198
+ $this->auto_iframe_tags = array_merge( $this->auto_iframe_tags, $args['iframes'] );
199
+ // array is multidimensional, assign per purpose
200
+ } else {
201
+ // block unassigned script
202
+ if ( array_key_exists( 0, $args['iframes'] ) ) {
203
+ $this->auto_iframe_tags = array_merge( $this->auto_iframe_tags, $args['iframes'][0] );
204
+ unset( $args['iframes'][0] );
205
+ }
206
+
207
+ $this->iframe_tags = $this->array_merge_custom( $this->iframe_tags, $args['iframes'] );
208
+ }
209
+ }
210
+
211
+ // get script tags to block
212
+ $this->auto_script_tags = array_unique( self::get_script_tags() );
213
+
214
+ // get iframes tags to block
215
+ $this->auto_iframe_tags = array_unique( self::get_iframe_tags() );
216
  }
217
 
218
  /**
230
  * @return boolean
231
  */
232
  static function consent_given() {
233
+ $consent_given = false;
234
+
235
  foreach ( $_COOKIE as $key => $value ) {
236
+ $found = self::strpos_array( $key, array( '_iub_cs-s', '_iub_cs' ) );
237
+
238
+ if ( $found !== false ) {
239
+ $consent_data = json_decode( stripslashes( $value ), true );
240
+
241
+ // read cookie value if given
242
+ if ( isset( $consent_data['consent'] ) && $consent_data['consent'] == true )
243
+ $consent_given = true;
244
+
245
+ // read purposes if given
246
+ if ( ! empty( $consent_data['purposes'] ) && is_array( $consent_data['purposes'] ) ) {
247
+ // all purposes accepted, consent given
248
+ if ( ! in_array( false, $consent_data['purposes'] ) )
249
+ $consent_given = true;
250
+ }
251
+ }
252
  }
253
 
254
+ return $consent_given;
255
  }
256
 
257
  /**
258
+ * Get user accepted purposes.
259
  *
260
+ * @return array
 
 
261
  */
262
+ static function get_purposes() {
263
+ $purposes = array();
 
264
 
265
+ if ( ! empty( $_COOKIE ) ) {
266
+ foreach ( $_COOKIE as $key => $value ) {
267
+ $found = self::strpos_array( $key, array( '_iub_cs-s', '_iub_cs' ) );
268
+
269
+ if ( $found !== false ) {
270
+ $consent_data = json_decode( $value, true );
271
+
272
+ // read purposes if given
273
+ if ( ! empty( $consent_data['purposes'] ) && is_array( $consent_data['purposes'] ) )
274
+ $purposes = $consent_data['purposes'];
275
+ }
 
 
 
 
 
276
  }
277
  }
278
+
279
+ return $purposes;
280
+ }
281
+
282
+ /**
283
+ * Get script tags to be blocked.
284
+ *
285
+ * @return array
286
+ */
287
+ private function get_script_tags() {
288
+ $tags = $this->auto_script_tags;
289
+
290
+ foreach ( $this->script_tags as $purpose_id => $tags_list ) {
291
+ // empty tags list, go to another
292
+ if ( empty( $tags_list ) )
293
+ continue;
294
+
295
+ // purposes available, filter per purpose
296
+ if ( ! empty( $this->purposes ) ) {
297
+ // don't block scripts unavailable in the user purposes
298
+ // if ( array_key_exists( $purpose_id, $this->purposes ) && $this->purposes[$purpose_id] == false ) {
299
+
300
+ // block scripts unavailable in the user purposes
301
+ if ( ! isset( $this->purposes[$purpose_id] ) || $this->purposes[$purpose_id] == false ) {
302
+ foreach ( $tags_list as $tag ) {
303
+ $tags[] = $tag;
304
+ }
305
+ }
306
+ // no purposes yet, just add all scripts
307
+ } else {
308
+ foreach ( $tags_list as $tag ) {
309
+ $tags[] = $tag;
310
+ }
311
+ }
312
+ }
313
+
314
+ return $tags;
315
+ }
316
+
317
+ /**
318
+ * Get iframe tags to be blocked.
319
+ *
320
+ * @return array
321
+ */
322
+ private function get_iframe_tags() {
323
+ $tags = $this->auto_iframe_tags;
324
+
325
+ foreach ( $this->iframe_tags as $purpose_id => $tags_list ) {
326
+ // empty tags list, go to another
327
+ if ( empty( $tags_list ) )
328
+ continue;
329
+
330
+ // purposes available, filter per purpose
331
+ if ( ! empty( $this->purposes ) ) {
332
+ // don't block iframes unavailable in the user purposes
333
+ // if ( array_key_exists( $purpose_id, $this->purposes ) && $this->purposes[$purpose_id] == false ) {
334
+
335
+ // block iframes unavailable in the user purposes
336
+ if ( ! isset( $this->purposes[$purpose_id] ) && $this->purposes[$purpose_id] == false ) {
337
+ foreach ( $tags_list as $tag ) {
338
+ $tags[] = $tag;
339
+ }
340
+ }
341
+ // no purposes yet, just add all scripts
342
+ } else {
343
+ foreach ( $tags_list as $tag ) {
344
+ $tags[] = $tag;
345
+ }
346
+ }
347
+ }
348
+
349
+ return $tags;
350
  }
351
 
352
  /**
355
  * @param mixed $content
356
  * @return mixed
357
  */
358
+ public function create_tags( $content, $args ) {
359
  $elements = $content->find( "*" );
360
  $js = '';
361
 
367
 
368
  switch ( $e->tag ) {
369
  case 'script':
370
+ if ( $args['pattern'] === 'IUB_REGEX_PURPOSE_PATTERN' )
371
+ $e->{'data-iub-purposes'} = $args['number'];
372
+
373
  $class = $e->class;
374
  $e->class = $class . ' ' . $this->iub_class;
375
  $e->type = 'text/plain';
377
  break;
378
 
379
  case 'iframe':
380
+ if ( $args['pattern'] === 'IUB_REGEX_PURPOSE_PATTERN' )
381
+ $e->{'data-iub-purposes'} = $args['number'];
382
+
383
  $new_src = $this->iub_empty;
384
  $class = $e->class;
385
  $e->suppressedsrc = $e->src;
389
  break;
390
 
391
  default:
392
+ $js .= $e->outertext;
393
  break;
394
  }
395
  }
416
 
417
  switch ( $element->tag ) {
418
  case 'script':
 
 
 
 
 
419
  case 'iframe':
420
  $class = trim( $element->class );
421
  $element->class = ( $class !== '' ? $class . ' ' : '' ) . $this->iub_class_skip;
441
  public function parse_scripts() {
442
  switch ( $this->type ) {
443
  case 'page':
444
+ // get page contents
445
+ $html = str_get_html( $this->content_page, true, true, false );
446
 
447
  if ( is_object( $html ) ) {
448
+ // get scripts
449
  $scripts = $html->find( 'script' );
450
 
451
  if ( is_array( $scripts ) ) {
452
  $count = count( $scripts );
453
  $class_skip = $this->iub_class_skip;
454
 
455
+ // loop through scripts
456
  for ( $j = 0; $j < $count; $j ++ ) {
457
  $s = $scripts[$j];
458
  $script_class = trim( $s->class );
473
 
474
  if ( ! empty( $s->innertext ) ) {
475
  $this->scripts_inline_detected[] = $s->innertext;
476
+
477
+ $found = self::strpos_array( $s->innertext, $this->auto_script_tags );
478
 
479
+ if ( $found !== false ) {
480
  $class = $s->class;
481
  $s->class = $class . ' ' . $this->iub_class_inline;
482
  $s->type = 'text/plain';
487
 
488
  if ( $src ) {
489
  $this->scripts_detected[] = $src;
490
+
491
+ $found = self::strpos_array( $src, $this->auto_script_tags );
492
 
493
+ if ( $found !== false ) {
494
  $class = $s->class;
495
  $s->class = $class . ' ' . $this->iub_class;
496
  $s->type = 'text/plain';
497
+
498
+ // add data-iub-purposes attribute
499
+ $s->{'data-iub-purposes'} = $this->recursive_array_search( $found, $this->script_tags );
500
+
501
  $this->scripts_converted[] = $src;
502
  }
503
  }
644
  // add inline script as detected
645
  if ( ! empty( $script->nodeValue ) )
646
  $this->scripts_inline_detected[] = $script->nodeValue;
647
+
648
+ $found = self::strpos_array( $src, $script_tags );
649
+ $found_inline = self::strpos_array( $script->nodeValue, $script_tags );
650
 
651
+ if ( $found !== false ) {
652
  $script->setAttribute( 'type', 'text/plain' );
653
  $script->setAttribute( 'class', $script->getAttribute( 'class' ) . ' ' . $class );
654
+
655
+ // add data-iub-purposes attribute
656
+ $script->setAttribute( 'data-iub-purposes', $this->recursive_array_search( $found, $this->script_tags ) );
657
 
658
  // add script as converted
659
  $this->scripts_converted[] = $src;
660
+ } elseif ( $found_inline !== false ) {
661
  $script->setAttribute( 'type', 'text/plain' );
662
  $script->setAttribute( 'class', $script->getAttribute( 'class' ) . ' ' . $class_inline );
663
 
687
  public function parse_iframes() {
688
  switch ( $this->type ) {
689
  case 'page':
690
+ $html = str_get_html( $this->content_page, true, true, false );
691
 
692
  if ( is_object( $html ) ) {
693
  $iframes = $html->find( 'iframe' );
714
  $src = $i->src;
715
  $this->iframes_detected[] = $src;
716
 
717
+ $found = self::strpos_array( $src, $this->auto_iframe_tags );
718
+
719
+ if ( $found !== false ) {
720
  $class = $i->class;
721
  $i->suppressedsrc = $src;
722
  $i->src = $this->iub_empty;
723
  $i->class = $class . ' ' . $this->iub_class;
724
+
725
+ // add data-iub-purposes attribute
726
+ $i->{'data-iub-purposes'} = $this->recursive_array_search( $found, $this->iframe_tags );
727
+
728
  $this->iframes_converted[] = $src;
729
  }
730
  }
775
 
776
  // add iframe as detected
777
  $this->iframes_detected[] = $src;
778
+
779
+ $found = self::strpos_array( $src, $iframe_tags );
780
 
781
+ if ( $found !== false ) {
782
  $iframe->setAttribute( 'src', $empty );
783
  $iframe->setAttribute( 'suppressedsrc', $src );
784
  $iframe->setAttribute( 'class', $iframe_class . ' ' . $class );
785
+
786
+ // per purpose, add data-iub-purposes attribute
787
+ $iframe->setAttribute( 'data-iub-purposes', $this->recursive_array_search( $found, $this->iframe_tags ) );
788
 
789
  // add iframe as converted
790
  $this->iframes_converted[] = $src;
823
  // get HTML dom from string
824
  $html = str_get_html( $scripts[1][$j], true, true, false );
825
 
826
+ // skip scripts and iframes inside iubenda's comments
827
  $js_scripts[] = $this->skip_tags( $html );
828
  }
829
 
834
  unset( $scripts );
835
 
836
  // block
837
+ foreach ( array( 'IUB_REGEX_PATTERN', 'IUB_REGEX_PATTERN_2', 'IUB_REGEX_PURPOSE_PATTERN' ) as $pattern ) {
838
  preg_match_all( constant( 'self::' . $pattern ), $this->content_page, $scripts );
839
 
840
+ $chunks = array();
841
+ $args = array(
842
+ 'pattern' => $pattern
843
+ );
844
+
845
+ if ( $pattern === 'IUB_REGEX_PURPOSE_PATTERN' ) {
846
+ $numbers = $scripts[1];
847
+ $chunks = $scripts[2];
848
+ } else
849
+ $chunks = $scripts[1];
850
+
851
  // found any content?
852
+ if ( is_array( $chunks ) ) {
853
+ $count = count( $chunks );
854
  $js_scripts = array();
855
 
856
  for ( $j = 0; $j < $count; $j++ ) {
857
+ $this->iub_comments_detected[] = $chunks[$j];
858
 
859
  // get HTML dom from string
860
+ $html = str_get_html( $chunks[$j], true, true, false );
861
+
862
+ if ( $pattern === 'IUB_REGEX_PURPOSE_PATTERN' )
863
+ $args['number'] = $numbers[$j];
864
 
865
  // convert scripts, iframes and other code inside IUBENDAs comment in text/plain to not generate cookies
866
+ $js_scripts[] = $this->create_tags( $html, $args );
867
  }
868
 
869
+ if ( ( is_array( $chunks ) && is_array( $js_scripts ) ) && ( $count >= 1 && count( $js_scripts ) >= 1 ) )
870
+ $this->content_page = strtr( $this->content_page, array_combine( $chunks, $js_scripts ) );
871
  }
872
  }
873
  }
905
  <script>
906
  var iCallback = function(){};
907
 
908
+ if ( 'callback' in _iub.csConfiguration ) {
909
+ if ( 'onConsentGiven' in _iub.csConfiguration.callback )
910
  iCallback = _iub.csConfiguration.callback.onConsentGiven;
911
 
912
  _iub.csConfiguration.callback.onConsentGiven = function() {
913
  iCallback();
914
 
915
+ jQuery( 'noscript._no_script_iub' ).each( function (a, b) { var el = jQuery(b); el.after( el.html() ); } );
916
  };
917
  };
918
  </script>";
919
  }
920
+
921
+ /**
922
+ * Static, utility function: strpos for array wilth wildcard support
923
+ *
924
+ * @param type $haystack
925
+ * @param type $needle
926
+ * @return boolean
927
+ */
928
+ static function strpos_array( $haystack, $needle ) {
929
+ if ( empty( $haystack ) || empty( $needle ) )
930
+ return false;
931
+
932
+ $needle = ! is_array( $needle ) ? array( $needle ) : $needle;
933
+
934
+ foreach ( $needle as $need ) {
935
+ // wildcard?
936
+ if ( strpos( $need, '/*/' ) !== false ) {
937
+ // strtok - removes query string
938
+ // str_replace - removes double slashes // from url
939
+ // preg_replace - removes http or https from url
940
+ $haystack = strtok( str_replace( '//', '', preg_replace( "(^https?://)", "", $haystack ) ), '?' );
941
+
942
+ if ( fnmatch( $need, $haystack ) !== false )
943
+ return $need;
944
+ // regular
945
+ } else {
946
+ if ( strpos( $haystack, $need ) !== false )
947
+ return $need;
948
+ }
949
+ }
950
+
951
+ return false;
952
+ }
953
+
954
+ /**
955
+ * Custom array merge helper function.
956
+ *
957
+ * @return array
958
+ */
959
+ public function array_merge_custom( $builtin, $data ) {
960
+ foreach ( $data as $type => $array ) {
961
+ // if ( $type === 0 )
962
+ // continue;
963
+
964
+ foreach ( $array as $block ) {
965
+ $builtin[$type][] = $block;
966
+ }
967
+
968
+ $builtin[$type] = array_unique( $builtin[$type] );
969
+ }
970
+
971
+ return $builtin;
972
+ }
973
+
974
+ /**
975
+ * Array search helper function.
976
+ *
977
+ * @param type $needle
978
+ * @param type $haystack
979
+ * @return boolean
980
+ */
981
+ public function recursive_array_search( $needle, $haystack ) {
982
+ foreach ( $haystack as $key => $value ) {
983
+ $current_key = $key;
984
+ if ( $needle === $value OR ( is_array( $value ) &&
985
+ $this->recursive_array_search( $needle, $value ) !== false) ) {
986
+ return $current_key;
987
+ }
988
+ }
989
+ return false;
990
+ }
991
+
992
  }
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: 2.0.2
7
  Author: iubenda
8
  Author URI: https://www.iubenda.com
9
  License: MIT License
@@ -32,7 +32,7 @@ define( 'IUB_DEBUG', false );
32
  * iubenda final class.
33
  *
34
  * @class iubenda
35
- * @version 2.0.2
36
  */
37
  class iubenda {
38
 
@@ -58,7 +58,7 @@ class iubenda {
58
  )
59
  );
60
  public $base_url;
61
- public $version = '2.0.2';
62
  public $no_html = false;
63
  public $multilang = false;
64
  public $languages = array();
@@ -111,6 +111,28 @@ class iubenda {
111
 
112
  $this->base_url = esc_url_raw( add_query_arg( 'page', 'iubenda', admin_url( $this->options['cs']['menu_position'] === 'submenu' ? 'options-general.php' : 'admin.php' ) ) );
113
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  // actions
115
  add_action( 'after_setup_theme', array( $this, 'register_shortcode' ) );
116
  add_action( 'wp_head', array( $this, 'wp_head_cs' ), 0 );
@@ -456,18 +478,22 @@ class iubenda {
456
 
457
  // google recaptcha v3 compatibility
458
  if ( class_exists( 'WPCF7' ) && (int) WPCF7::get_option( 'iqfix_recaptcha' ) === 0 && ! iubendaParser::consent_given() )
459
- $this->options['cs']['custom_scripts'][] = 'grecaptcha';
460
 
461
  // Jetpack compatibility
462
  if ( class_exists( 'Jetpack' ) )
463
- $this->options['cs']['custom_scripts'][] = 'stats.wp.com';
464
 
465
  $startime = microtime( true );
466
  $output = apply_filters( 'iubenda_initial_output', $output );
467
 
 
 
 
 
468
  // experimental class
469
  if ( $this->options['cs']['parser_engine'] == 'new' ) {
470
- $iubenda = new iubendaParser( mb_convert_encoding( $output, 'HTML-ENTITIES', 'UTF-8' ), array( 'type' => 'faster', 'scripts' => $this->options['cs']['custom_scripts'], 'iframes' => $this->options['cs']['custom_iframes'] ) );
471
 
472
  // render output
473
  $output = $iubenda->parse();
@@ -476,7 +502,7 @@ class iubenda {
476
  $output .= '<!-- Parsed with iubenda experimental class in ' . round( microtime( true ) - $startime, 4 ) . ' sec. -->';
477
  // default class
478
  } else {
479
- $iubenda = new iubendaParser( $output, array( 'type' => 'page', 'scripts' => $this->options['cs']['custom_scripts'], 'iframes' => $this->options['cs']['custom_iframes'] ) );
480
 
481
  // render output
482
  $output = $iubenda->parse();
@@ -488,6 +514,25 @@ class iubenda {
488
  return apply_filters( 'iubenda_final_output', $output );
489
  }
490
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
491
  /**
492
  * Parse iubenda code.
493
  *
@@ -532,8 +577,8 @@ class iubenda {
532
  if ( ! class_exists( 'Jetpack' ) )
533
  return;
534
 
535
- // disable if it's not AMP cached request
536
- if ( ! Jetpack_AMP_Support::is_amp_request() )
537
  return;
538
 
539
  // if ( is_feed() || is_robots() || is_trackback() || is_preview() || jetpack_is_dnt_enabled() )
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: 2.1.0
7
  Author: iubenda
8
  Author URI: https://www.iubenda.com
9
  License: MIT License
32
  * iubenda final class.
33
  *
34
  * @class iubenda
35
+ * @version 2.1.0
36
  */
37
  class iubenda {
38
 
58
  )
59
  );
60
  public $base_url;
61
+ public $version = '2.1.0';
62
  public $no_html = false;
63
  public $multilang = false;
64
  public $languages = array();
111
 
112
  $this->base_url = esc_url_raw( add_query_arg( 'page', 'iubenda', admin_url( $this->options['cs']['menu_position'] === 'submenu' ? 'options-general.php' : 'admin.php' ) ) );
113
 
114
+ // check old custom scripts
115
+ if ( ! empty( $this->options['cs']['custom_scripts'] ) && is_array( $this->options['cs']['custom_scripts'] ) && ! is_int( reset( $this->options['cs']['custom_scripts'] ) ) ) {
116
+ $data = array();
117
+
118
+ foreach ( $this->options['cs']['custom_scripts'] as $script ) {
119
+ $data[$script] = 0;
120
+ }
121
+
122
+ $this->options['cs']['custom_scripts'] = $data;
123
+ }
124
+
125
+ // check old custom iframes
126
+ if ( ! empty( $this->options['cs']['custom_iframes'] ) && is_array( $this->options['cs']['custom_iframes'] ) && ! is_int( reset( $this->options['cs']['custom_iframes'] ) ) ) {
127
+ $data = array();
128
+
129
+ foreach ( $this->options['cs']['custom_iframes'] as $iframe ) {
130
+ $data[$iframe] = 0;
131
+ }
132
+
133
+ $this->options['cs']['custom_iframes'] = $data;
134
+ }
135
+
136
  // actions
137
  add_action( 'after_setup_theme', array( $this, 'register_shortcode' ) );
138
  add_action( 'wp_head', array( $this, 'wp_head_cs' ), 0 );
478
 
479
  // google recaptcha v3 compatibility
480
  if ( class_exists( 'WPCF7' ) && (int) WPCF7::get_option( 'iqfix_recaptcha' ) === 0 && ! iubendaParser::consent_given() )
481
+ $this->options['cs']['custom_scripts']['grecaptcha'] = 2;
482
 
483
  // Jetpack compatibility
484
  if ( class_exists( 'Jetpack' ) )
485
+ $this->options['cs']['custom_scripts']['stats.wp.com'] = 5;
486
 
487
  $startime = microtime( true );
488
  $output = apply_filters( 'iubenda_initial_output', $output );
489
 
490
+ // prepare scripts and iframes
491
+ $scripts = $this->prepare_custom_data( $this->options['cs']['custom_scripts'] );
492
+ $iframes = $this->prepare_custom_data( $this->options['cs']['custom_iframes'] );
493
+
494
  // experimental class
495
  if ( $this->options['cs']['parser_engine'] == 'new' ) {
496
+ $iubenda = new iubendaParser( mb_convert_encoding( $output, 'HTML-ENTITIES', 'UTF-8' ), array( 'type' => 'faster', 'scripts' => $scripts, 'iframes' => $iframes ) );
497
 
498
  // render output
499
  $output = $iubenda->parse();
502
  $output .= '<!-- Parsed with iubenda experimental class in ' . round( microtime( true ) - $startime, 4 ) . ' sec. -->';
503
  // default class
504
  } else {
505
+ $iubenda = new iubendaParser( $output, array( 'type' => 'page', 'scripts' => $scripts, 'iframes' => $iframes ) );
506
 
507
  // render output
508
  $output = $iubenda->parse();
514
  return apply_filters( 'iubenda_final_output', $output );
515
  }
516
 
517
+ /**
518
+ * Prepare scripts/iframes.
519
+ *
520
+ * @param array $data
521
+ * @return array
522
+ */
523
+ public function prepare_custom_data( $data ) {
524
+ $newdata = array();
525
+
526
+ foreach ( $data as $script => $type ) {
527
+ if ( ! array_key_exists( $type, $newdata ) )
528
+ $newdata[$type] = array();
529
+
530
+ $newdata[$type][] = $script;
531
+ }
532
+
533
+ return $newdata;
534
+ }
535
+
536
  /**
537
  * Parse iubenda code.
538
  *
577
  if ( ! class_exists( 'Jetpack' ) )
578
  return;
579
 
580
+ // disable if it's not AMP cached request
581
+ if ( ! class_exists( 'Jetpack_AMP_Support' ) || ! Jetpack_AMP_Support::is_amp_request() )
582
  return;
583
 
584
  // if ( is_feed() || is_robots() || is_trackback() || is_preview() || jetpack_is_dnt_enabled() )
js/admin.js CHANGED
@@ -1,11 +1,8 @@
1
  ( function ( $ ) {
2
 
3
  $( document ).ready( function () {
4
-
5
  // parse args
6
  var args = $.parseJSON( iubAdminArgs );
7
-
8
- // console.log( args );
9
 
10
  // read more option
11
  $( '#iub_parse' ).change( function () {
@@ -55,7 +52,7 @@
55
 
56
  $( '#postbox-container-2' ).change();
57
 
58
- html = $( '#preferences-field-template' ).html();
59
  html = html.replace( /__PREFERENCE_ID__/g, preferencesID++ );
60
 
61
  $( '.preferences-table .add-preferences-field' ).closest( 'tr' ).before( '<tr class="preferences-field options-field" style="display: none;">' + html + '</tr>' );
@@ -87,7 +84,7 @@
87
 
88
  $( '#postbox-container-2' ).change();
89
 
90
- html = $( '#exclude-field-template' ).html();
91
  html = html.replace( /__EXCLUDE_ID__/g, excludeID++ );
92
 
93
  $( '.exclude-table .add-exclude-field' ).closest( 'tr' ).before( '<tr class="exclude-field options-field" style="display: none;">' + html + '</tr>' );
@@ -117,7 +114,7 @@
117
 
118
  $( '#postbox-container-2' ).change();
119
 
120
- html = $( '#legal_notices-field-template' ).html();
121
  html = html.replace( /__LEGAL_NOTICE_ID__/g, legalNoticesID++ );
122
 
123
  console.log( html );
@@ -139,7 +136,41 @@
139
  $( this ).remove();
140
  } );
141
  } );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
 
 
 
 
 
 
 
 
 
 
143
  // Remove template fields on save
144
  $( document ).on( 'click', '#publish', function () {
145
  $( '#preferences-field-template' ).remove();
1
  ( function ( $ ) {
2
 
3
  $( document ).ready( function () {
 
4
  // parse args
5
  var args = $.parseJSON( iubAdminArgs );
 
 
6
 
7
  // read more option
8
  $( '#iub_parse' ).change( function () {
52
 
53
  $( '#postbox-container-2' ).change();
54
 
55
+ var html = $( '#preferences-field-template' ).html();
56
  html = html.replace( /__PREFERENCE_ID__/g, preferencesID++ );
57
 
58
  $( '.preferences-table .add-preferences-field' ).closest( 'tr' ).before( '<tr class="preferences-field options-field" style="display: none;">' + html + '</tr>' );
84
 
85
  $( '#postbox-container-2' ).change();
86
 
87
+ var html = $( '#exclude-field-template' ).html();
88
  html = html.replace( /__EXCLUDE_ID__/g, excludeID++ );
89
 
90
  $( '.exclude-table .add-exclude-field' ).closest( 'tr' ).before( '<tr class="exclude-field options-field" style="display: none;">' + html + '</tr>' );
114
 
115
  $( '#postbox-container-2' ).change();
116
 
117
+ var html = $( '#legal_notices-field-template' ).html();
118
  html = html.replace( /__LEGAL_NOTICE_ID__/g, legalNoticesID++ );
119
 
120
  console.log( html );
136
  $( this ).remove();
137
  } );
138
  } );
139
+
140
+ // add new script field
141
+ $( document ).on( 'click', '.add-custom-script-field', function( e ) {
142
+ e.preventDefault();
143
+
144
+ $( this ).before( '<div class="custom-script-field" style="display: none;">' + $( '#custom-script-field-template' ).html() + '</div>' );
145
+ $( '#tab-panel-scripts' ).find( '.custom-script-field' ).last().fadeIn( 300 );
146
+ } );
147
+
148
+ // remove custom script field
149
+ $( document ).on( 'click', '.remove-custom-script-field', function( e ) {
150
+ e.preventDefault();
151
+
152
+ $( this ).closest( '.custom-script-field' ).fadeOut( 300, function() {
153
+ $( this ).remove();
154
+ } );
155
+ } );
156
+
157
+ // add new iframe field
158
+ $( document ).on( 'click', '.add-custom-iframe-field', function( e ) {
159
+ e.preventDefault();
160
+
161
+ $( this ).before( '<div class="custom-iframe-field" style="display: none;">' + $( '#custom-iframe-field-template' ).html() + '</div>' );
162
+ $( '#tab-panel-iframes' ).find( '.custom-iframe-field' ).last().fadeIn( 300 );
163
+ } );
164
 
165
+ // remove custom iframe field
166
+ $( document ).on( 'click', '.remove-custom-iframe-field', function( e ) {
167
+ e.preventDefault();
168
+
169
+ $( this ).closest( '.custom-iframe-field' ).fadeOut( 300, function() {
170
+ $( this ).remove();
171
+ } );
172
+ } );
173
+
174
  // Remove template fields on save
175
  $( document ).on( 'click', '#publish', function () {
176
  $( '#preferences-field-template' ).remove();
languages/iubenda-cookie-law-solution-it_IT.mo CHANGED
Binary file
languages/iubenda-cookie-law-solution-it_IT.po CHANGED
@@ -1,8 +1,8 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Iubenda Cookie Solution\n"
4
- "POT-Creation-Date: 2019-11-12 15:08+0100\n"
5
- "PO-Revision-Date: 2019-11-14 12:07+0100\n"
6
  "Last-Translator: \n"
7
  "Language-Team: \n"
8
  "Language: it\n"
@@ -25,7 +25,9 @@ msgid "Form ID"
25
  msgstr "ID del form"
26
 
27
  #: includes/forms-list-table.php:94
28
- msgid "Source"
 
 
29
  msgstr "Fonte"
30
 
31
  #: includes/forms-list-table.php:95
@@ -60,7 +62,7 @@ msgstr "Tutte le fonti"
60
  msgid "No forms found."
61
  msgstr "Nessun form trovato."
62
 
63
- #: includes/forms.php:149 includes/settings.php:126
64
  msgid "Forms"
65
  msgstr "Form"
66
 
@@ -69,17 +71,14 @@ msgid "Form"
69
  msgstr "Form"
70
 
71
  #: includes/forms.php:566 includes/forms.php:580
72
- #, php-format
73
  msgid "First name"
74
  msgstr "Nome"
75
 
76
  #: includes/forms.php:572 includes/forms.php:592
77
- #, php-format
78
  msgid "Last name"
79
  msgstr "Cognome"
80
 
81
  #: includes/forms.php:586
82
- #, php-format
83
  msgid "Middle name"
84
  msgstr "Secondo nome"
85
 
@@ -88,253 +87,334 @@ msgstr "Secondo nome"
88
  msgid "string"
89
  msgstr "stringa"
90
 
91
- #: includes/settings.php:57 includes/settings.php:171
92
  msgid "Cookie Solution"
93
  msgstr "Cookie Solution"
94
 
95
- #: includes/settings.php:63 includes/settings.php:172
96
  msgid "Consent Solution"
97
  msgstr "Consent Solution"
98
 
99
- #: includes/settings.php:114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  msgid "Code"
101
  msgstr "Codice"
102
 
103
- #: includes/settings.php:115
104
  #, fuzzy
105
  #| msgid "Scripts blocking"
106
  msgid "Script blocking"
107
  msgstr "Blocco preventivo dei codici"
108
 
109
- #: includes/settings.php:116
110
  msgid "Custom scripts"
111
  msgstr "Script personalizzati"
112
 
113
- #: includes/settings.php:117
114
  msgid "Content type"
115
  msgstr "Tipo di contenuto"
116
 
117
- #: includes/settings.php:118
118
  msgid "RSS feed"
119
  msgstr "Feed RSS"
120
 
121
- #: includes/settings.php:119
122
  msgid "POST requests"
123
  msgstr "Richieste POST"
124
 
125
- #: includes/settings.php:120
126
  msgid "Menu position"
127
  msgstr "Posizione menu"
128
 
129
- #: includes/settings.php:121
130
  msgid "Deactivation"
131
  msgstr "Disattivazione"
132
 
133
- #: includes/settings.php:127
134
- msgid "Public API Key"
 
 
135
  msgstr "Chiave API pubblica"
136
 
137
- #: includes/settings.php:130 includes/settings.php:134
138
  msgid "Field Mapping"
139
  msgstr "Mapping dei campi"
140
 
141
- #: includes/settings.php:192
142
  msgid "Are you sure you want to delete this form?"
143
  msgstr "Sei sicuro di voler eliminare questo form?"
144
 
145
- #: includes/settings.php:340
146
  msgid "You don't have permission to access this page."
147
  msgstr "Non disponi dell'autorizzazione per accedere a questa pagina."
148
 
149
- #: includes/settings.php:357
150
  #, fuzzy
151
  #| msgid ""
152
- #| "This plugin is the easiest and most comprehensive way to adapt your WordPress "
153
- #| "site to the European cookie law. Upon your user's first visit, the plugin "
154
- #| "will take care of collecting their consent, of blocking the most popular "
155
- #| "among the scripts that install cookies and subsequently reactivate these "
156
- #| "scripts as soon as consent is provided. The basic settings include obtaining "
157
- #| "consent by a simple scroll action (the most effective method) and script "
158
- #| "reactivation without refreshing the page."
159
  msgid ""
160
- "This plugin is the easiest and most comprehensive way to adapt your WordPress "
161
- "site to the ePrivacy (EU Cookie Law). Upon your users’ first visit, the plugin "
162
- "will take care of collecting their consent, blocking the most popular cookie-"
163
- "scripts and subsequently reactivating these scripts as soon as consent is "
164
- "provided. The basic settings include obtaining consent by a simple scroll action "
165
- "(the most effective method) and script reactivation without refreshing the page "
166
- "(asynchronous script reactivation)."
167
  msgstr ""
168
  "Questo plugin è il modo più semplice e completo per adeguare il tuo sito "
169
- "WordPress alla Direttiva ePrivacy (Cookie Law). Alla prima visita dell'utente il "
170
- "plugin si occuperà di raccoglierne il consenso, bloccare gli script più popolari "
171
- "che installano cookie e riattivarli non appena il consenso viene fornito. Le "
172
- "impostazioni di base includono la raccolta del consenso tramite il semplice "
173
- "scroll (il metodo più efficace) e la riattivazione senza il refresh della pagina."
 
174
 
175
- #: includes/settings.php:360
176
- msgid "Does the Cookie Solution support IAB’s Transparency and Consent Framework?"
177
- msgstr "La Cookie Solution supporta il Transparency e Consent Framework di IAB?"
 
 
178
 
179
- #: includes/settings.php:361
180
  #, fuzzy, php-format
181
  #| msgid ""
182
- #| "Visit our <a href=\"%s\" class=\"iubenda-url\" target=\"_blank\">plugin page."
183
- #| "</a>"
184
  msgid ""
185
  "Yes it does. You can read more about it <a href=\"%s\" class=\"iubenda-url\" "
186
  "target=\"_blank\">here.</a>"
187
  msgstr ""
188
- "Sì. Visita <a href=\"%s\" class=\"iubenda-url\" target=\"_blank\">questa pagina</"
189
- "a> per maggiori dettagli."
190
 
191
- #: includes/settings.php:364
192
- msgid "Would you like to know more about the Cookie Law?"
 
 
193
  msgstr "Vuoi saperne di più sulla Cookie Law?"
194
 
195
- #: includes/settings.php:365
196
- #, php-format
 
 
 
197
  msgid ""
198
- "Read our <a href=\"%s\" class=\"iubenda-url\" target=\"_blank\">complete guide "
199
- "to the Cookie Law</a>."
200
  msgstr ""
201
  "Leggi la nostra <a href=\"%s\" class=\"iubenda-url\" target=\"_blank\">guida "
202
  "completa alla Cookie Law</a>."
203
 
204
- #: includes/settings.php:368
205
  msgid "What is the full functionality of the plugin?"
206
  msgstr "Quali sono le funzionalità del plugin?"
207
 
208
- #: includes/settings.php:369
209
- #, php-format
 
 
 
210
  msgid ""
211
- "Visit our <a href=\"%s\" class=\"iubenda-url\" target=\"_blank\">plugin page</a>."
 
212
  msgstr ""
213
  "Visita la <a href=\"%s\" class=\"iubenda-url\" target=\"_blank\">pagina "
214
  "dedicata</a> al plugin."
215
 
216
- #: includes/settings.php:372
217
  msgid "Enter the iubenda code for the Cookie Solution below."
218
  msgstr "Inserisci qui sotto il codice di iubenda per la Cookie Solution."
219
 
220
- #: includes/settings.php:373
221
  #, php-format
222
  msgid ""
223
- "In order to run the plugin, you need to enter the iubenda code that activates "
224
- "the cookie law banner and the cookie policy in the form below. This code can be "
225
- "generated on www.iubenda.com, following <a href=\"%s\" class=\"iubenda-url\" "
226
- "target=\"_blank\">this guide.</a>"
227
  msgstr ""
228
  "Per far funzionare il plugin, è necessario inserire nel form sottostante il "
229
- "codice di iubenda che attiva il cookie banner e la cookie policy. Questo codice "
230
- "può essere generato su www.iubenda.com seguendo le istruzioni contenute in <a "
231
- "href=\"%s\" class=\"iubenda-url\" target=\"_blank\">questa guida</a>."
 
232
 
233
- #: includes/settings.php:378
 
 
 
 
 
 
 
 
 
234
  msgid ""
235
  "Maintaining comprehensive records of consent is a vital part of privacy "
236
- "compliance in general but is specifically required under the GDPR. These records "
237
- "should include a way of identifying the user, store proof of consent, record of "
238
- "the consenting action, and the legal documents available to the user at the time "
239
- "of consent, among other things. You can read about the <a href=\"https://www."
240
- "iubenda.com/en/help/5428#records-of-consent\" target=\"_blank\">full "
241
- "requirements here</a>."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  msgstr ""
243
- "Oltre ad essere un elemento vitale per il rispetto della privacy in generale, il "
244
- "mantenimento di un registro dei consensi è specificamente richiesto dal GDPR. "
245
- "Tra le altre cose, tale registro dovrebbe includere un modo per identificare "
246
- "l'utente, la prova del consenso, la registrazione dell'azione di consenso e i "
247
- "documenti legali messi a disposizione dell'utente al momento del consenso. <a "
248
- "href=\"https://www.iubenda.com/it/help/5424#registro-consensi\" target=\"_blank"
249
- "\">Trovi tutti i requisiti qui</a>."
250
-
251
- #: includes/settings.php:402
252
  #, php-format
253
  msgid ""
254
- "This plugin drastically reduces the need for direct interventions in the code of "
255
- "the site by integrating with iubenda’s Cookie Solution. It provides a fully "
256
- "customizable cookie banner, dynamically generates a cookie policy <a href=\"%s\" "
257
- "target=\"_blank\">to match the services in use on your site</a>, and, fully "
258
- "manages cookie-related consent – including the blocking of the most common "
259
- "widgets and third-party cookies before consent is received – in order to comply "
260
- "with the GDPR and ePrivacy."
261
  msgstr ""
262
- "Grazie all'integrazione con la Cookie Solution di iubenda, questo plugin riduce "
263
- "drasticamente la necessità di interventi diretti sul codice del sito. Prevede un "
264
- "cookie banner completamente personalizzabile, genera una cookie policy che <a "
265
- "href=\"%s\" target=\"_blank\">rispecchia i servizi in uso dal tuo sito web</a> e "
266
- "gestisce il consenso ai cookie (incluso il blocco automatico dei widget e dei "
267
- "cookie di terza parte più diffusi) in modo da permetterti di rispettare il GDPR "
268
- "e la Direttiva ePrivacy."
269
-
270
- #: includes/settings.php:404
271
  msgid ""
272
- "Maintaining valid records of consent is a vital part of privacy compliance in "
273
- "general, and it is specifically required under the GDPR. These records should "
274
- "include a userid, timestamp, consent proof, record of the consenting action, and "
275
- "the legal documents available to the user at the time of consent, among other "
276
- "things. This plugin is THE most complete solution for recording, sorting and "
277
- "maintaining GDPR records of consent*. The plugin also boasts built-in "
278
- "compatibility with WordPress comment form, Contact Form 7 and WP Forms plugins "
279
- "for your convenience, but can be manually integrated with any type of web-form "
280
- "and can even store consent proofs for consents collected offline (e.g in-store "
281
- "sign-ups) via WP media upload."
282
  msgstr ""
283
- "Il mantenimento di un valido registro dei consensi è un elemento vitale per il "
284
- "rispetto della privacy, ed è specificamente richiesto dal GDPR. Tra le altre "
285
- "cose, questo registro dovrebbe includere l'identificativo dell'utente, il "
286
- "timestamp, la prova del consenso, la registrazione dell'azione di consenso e i "
287
- "documenti legali messi a disposizione dell'utente nel momento in cui il consenso "
288
- "è stato acquisito. Questo plugin è la soluzione più completa per la creazione e "
289
- "la gestione di un registro dei consensi*. Il plugin è compatibile con il modulo "
290
- "dei commenti WordPress e i plugin Contact Form 7 e WP Forms, può essere "
291
- "integrato manualmente con qualsiasi form e può memorizzare la prova del consenso "
292
- "anche per i consensi raccolti offline (ad esempio, le iscrizioni in-store) "
293
- "tramite l'upload dei media WP."
294
-
295
- #: includes/settings.php:422
296
  msgid "Reset to defaults"
297
  msgstr "Ripristina le impostazioni di default"
298
 
299
- #: includes/settings.php:434
300
  msgid "Need support for this plugin?"
301
  msgstr "Serve aiuto per questo plugin?"
302
 
303
- #: includes/settings.php:435
304
  #, php-format
305
  msgid ""
306
- "Visit our <a href=\"%s\" class=\"iubenda-url\" target=\"_blank\">support forum.</"
307
- "a>"
308
  msgstr ""
309
- "Visita il nostro <a href=\"%s\" class=\"iubenda-url\" target=\"_blank\">forum di "
310
- "supporto</a>"
311
 
312
- #: includes/settings.php:479
313
  #, php-format
314
  msgid "Enter the iubenda code for %s."
315
  msgstr "Inserisci il codice di iubenda per %s."
316
 
317
- #: includes/settings.php:490
318
  msgid "Enter the iubenda code."
319
  msgstr "Inserisci il codice di iubenda."
320
 
321
- #: includes/settings.php:518
322
  #, fuzzy
323
  #| msgid "Enter a list of custom scripts (one per line)."
324
- msgid "Enter the list of custom scripts you’d like to block here (one per line)"
 
 
325
  msgstr "Elenca gli script personalizzati (uno per riga)."
326
 
327
- #: includes/settings.php:522
 
 
 
 
 
 
 
 
 
 
 
 
 
 
328
  #, fuzzy
329
  #| msgid "Enter a list of custom iframes (one per line)."
330
- msgid "Enter the list of custom iframes you’d like to block here (one per line)."
 
 
331
  msgstr "Elenca gli iframe personalizzati (uno per riga)."
332
 
333
- #: includes/settings.php:537
 
 
 
 
334
  msgid "Automatically block scripts detected by the plugin."
335
  msgstr "Blocca automaticamente gli script rilevati dal plugin."
336
 
337
- #: includes/settings.php:538
338
  #, php-format
339
  msgid ""
340
  "see <a href=\"%s\" target=\"_blank\">our documentation</a> for the list of "
@@ -343,286 +423,297 @@ msgstr ""
343
  "visita <a href=\"%s\" target=\"_blank\">la nostra documentazione</a> per la "
344
  "lista degli script rilevati automaticamente dal plugin."
345