iubenda Cookie Solution for GDPR - Version dev

Version Description

Download this release

Release Info

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

Code changes from version 2.5.1 to dev

css/admin.css CHANGED
@@ -161,4 +161,64 @@
161
  }
162
  .iubenda-notice .reply-no:before {
163
  content: "\f335";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  }
161
  }
162
  .iubenda-notice .reply-no:before {
163
  content: "\f335";
164
+ }
165
+
166
+ .switch {
167
+ position: relative;
168
+ display: inline-block;
169
+ width: 32px;
170
+ height: 20px;
171
+ }
172
+
173
+ .switch input {
174
+ opacity: 0;
175
+ width: 0;
176
+ height: 0;
177
+ }
178
+
179
+ .slider {
180
+ position: absolute;
181
+ cursor: pointer;
182
+ top: 0;
183
+ left: -5px;
184
+ right: -10px;
185
+ bottom: 0;
186
+ background-color: #ccc;
187
+ -webkit-transition: .4s;
188
+ transition: .4s;
189
+ }
190
+
191
+ .slider:before {
192
+ position: absolute;
193
+ content: "";
194
+ height: 18px;
195
+ width: 18px;
196
+ left: 2px;
197
+ background-color: white;
198
+ -webkit-transition: .4s;
199
+ transition: .4s;
200
+ top: 1px;
201
+ }
202
+
203
+ input:checked + .slider {
204
+ background-color: #1CC691;
205
+ }
206
+
207
+ input:focus + .slider {
208
+ box-shadow: 0 0 1px #1CC691;
209
+ }
210
+
211
+ input:checked + .slider:before {
212
+ -webkit-transform: translateX(26px);
213
+ -ms-transform: translateX(26px);
214
+ transform: translateX(26px);
215
+ }
216
+
217
+ /* Rounded sliders */
218
+ .slider.round {
219
+ border-radius: 34px;
220
+ }
221
+
222
+ .slider.round:before {
223
+ border-radius: 50%;
224
  }
includes/forms.php CHANGED
@@ -1152,13 +1152,8 @@ class iubenda_Forms {
1152
  continue;
1153
  }
1154
 
1155
- $name = trim( $form->form_fields[ $index ]['name'], 'wpforms' );
1156
- $array_key = substr( str_replace( '][', '.', $name ), 1, - 1 );
1157
- // Special handling for checkboxes, By checking the name is ending with array brackets
1158
- if ( '[]' === substr( $name, - 2 ) ) {
1159
- $array_key .= '0';
1160
- }
1161
-
1162
  $data[ $key ][ $map_key ] = $this->array_get( $entry, $array_key );
1163
  }
1164
 
1152
  continue;
1153
  }
1154
 
1155
+ $array_key = trim( $form->form_fields[ $index ]['name'], 'wpforms' );
1156
+ $array_key = substr( str_replace( '][', '.', $array_key ), 1, - 1 );
 
 
 
 
 
1157
  $data[ $key ][ $map_key ] = $this->array_get( $entry, $array_key );
1158
  }
1159
 
includes/script-list-table.php ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // exit if accessed directly
3
+ if ( ! defined( 'ABSPATH' ) )
4
+ exit;
5
+
6
+ /**
7
+ * iubenda_List_Table_Forms class.
8
+ *
9
+ * @class iubenda_List_Table_Forms
10
+ */
11
+ class iubenda_List_Table_Scripts extends WP_List_Table {
12
+
13
+ public $items;
14
+ public $extra_items;
15
+ public $base_url;
16
+ private $saved_options;
17
+
18
+ private $purpose_definitions = [
19
+ 1 => 'Strictly necessary',
20
+ 2 => 'Basic interactions & functionalities',
21
+ 3 => 'Experience enhancement',
22
+ 4 => 'Analytics',
23
+ 5 => 'Targeting & Advertising',
24
+ ];
25
+
26
+ /**
27
+ * Class constructor.
28
+ */
29
+ public function __construct() {
30
+ // set parent defaults
31
+ parent::__construct( array(
32
+ 'ajax' => false
33
+ ) );
34
+
35
+ $this->base_url = esc_url_raw( add_query_arg( array( 'tab' => 'test' ), iubenda()->base_url ) );
36
+ }
37
+
38
+ protected function fetchSiteScripts() {
39
+ $recognised_scripts = array();
40
+ $posts = new WP_Query( array('post_type' => 'any', 'posts_per_page' => '-1', 'post_status' => 'publish' ) );
41
+ foreach ( $posts->posts as $post ) {
42
+ $html = file_get_contents( get_permalink( $post->ID ) );
43
+ $recognised_scripts = array_merge( $recognised_scripts, (new iubendaParser() )->get_scripts_from_html( $html ));
44
+ $recognised_scripts = array_unique($recognised_scripts);
45
+ }
46
+
47
+ return $recognised_scripts;
48
+ }
49
+
50
+
51
+ /**
52
+ * Prepare the items for the table to process.
53
+ */
54
+ public function prepare_items() {
55
+ $scripts = file_get_contents(__DIR__ . '/../scripts.json');
56
+ $scripts = json_decode($scripts, true);
57
+ $items = [];
58
+ $found_scripts = $this->fetchSiteScripts();
59
+ foreach ( $found_scripts as $found_script ) {
60
+ foreach ( $scripts as $script ) {
61
+ $src = $script['script'];
62
+ $exist = iubendaParser::strpos_array($found_script, $src);
63
+ if ( $exist ) {
64
+ $items[] = $script;
65
+ }
66
+ }
67
+ }
68
+
69
+ $per_page = 20;
70
+ // echo '<pre>'; print_r( $items ); echo '</pre>';
71
+ if ( is_array( $items ) ) {
72
+ $this->items = array_slice( $items, 0, $per_page );
73
+ $this->extra_items = array_slice( $items, $per_page );
74
+ }
75
+ // echo '<pre>'; print_r( $this->extra_items ); echo '</pre>';
76
+ $this->set_pagination_args( array(
77
+ 'total_items' => count( $items ),
78
+ 'per_page' => $per_page,
79
+ ) );
80
+
81
+ $columns = $this->get_columns();
82
+ $hidden = array();
83
+ $this->_column_headers = array( $columns, $hidden );
84
+ $this->saved_options = get_option( 'iub_active_scanned_scripts', array() );
85
+ }
86
+
87
+ /**
88
+ * Override the parent columns method. Defines the columns to use in your listing table.
89
+ *
90
+ * @return array
91
+ */
92
+ public function get_columns() {
93
+ $columns = array(
94
+ 'cb' => '<input type="checkbox"/>',
95
+ 'title' => __( 'Name', 'iubenda' ),
96
+ 'script' => __( 'Script', 'iubenda' ),
97
+ 'purpose' => __( 'Purpose', 'iubenda' ),
98
+ 'status' => __( 'Status', 'iubenda' ),
99
+ );
100
+
101
+ return $columns;
102
+ }
103
+
104
+ /**
105
+ * Handle single row content.
106
+ *
107
+ * @param array $item
108
+ * @return mixed
109
+ */
110
+ public function single_row( $item ) {
111
+ ?>
112
+ <tr>
113
+ <?php $this->single_row_columns( $item ); ?>
114
+ </tr>
115
+ <?php
116
+ }
117
+
118
+ /**
119
+ * Get the name of the default primary column.
120
+ *
121
+ * @return string Name of the default primary column, in this case, 'title'.
122
+ */
123
+ public function get_default_primary_column_name() {
124
+ return 'title';
125
+ }
126
+
127
+ /**
128
+ * Define what data to show on each column of the table.
129
+ *
130
+ * @param array $item
131
+ * @param string $column_name
132
+ * @return mixed
133
+ */
134
+ public function column_default( $item, $column_name ) {
135
+ $output = '';
136
+
137
+ // get columns content
138
+ switch ( $column_name ) {
139
+ case 'title':
140
+ $output = $item['name'];
141
+ break;
142
+ case 'status':
143
+ $is_checked = boolval( @$this->saved_options[ $item['name'] ] ) ? 'checked' : '';
144
+ $json = json_encode($item);
145
+ $ajax_url = admin_url( 'admin-ajax.php' );
146
+ $output = "<label class='switch'>
147
+ <input class='toggle-scanned-script-status' data-ajax-url='{$ajax_url}' data-item='{$json}' {$is_checked} type='checkbox'><span class='slider round'></span>
148
+ </label>";
149
+ break;
150
+ case 'purpose':
151
+ $output = $this->purpose_definitions[$item['purpose']];
152
+ break;
153
+ case 'script':
154
+ $output = $item['script'];
155
+ default:
156
+ break;
157
+ }
158
+
159
+ return $output;
160
+ }
161
+
162
+ /**
163
+ * Display checkboxex callback.
164
+ *
165
+ * @return string
166
+ */
167
+ public function column_cb( $item ) {
168
+ return sprintf(
169
+ '<input type="checkbox" name="%1$s[]" value="%2$s" />', 'form', $item['name']
170
+ );
171
+ }
172
+
173
+ /**
174
+ * Display empty result.
175
+ *
176
+ * @return string
177
+ */
178
+ public function no_items() {
179
+ echo __( 'No Scripts found.', 'iubenda' );
180
+ }
181
+
182
+ }
includes/script-scanner.php ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // exit if accessed directly
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * iubenda_Settings class.
9
+ *
10
+ * @class Post_Views_Counter_Settings
11
+ */
12
+ class ScriptScanner extends iubenda_Settings {
13
+
14
+ public function __construct() {
15
+ add_action( 'admin_menu', array( $this, 'admin_menu_options' ) );
16
+ add_action( 'admin_init', array( $this, 'register_options' ) );
17
+ add_action('wp_ajax_toggle_scanned_script', array($this ,'toggle_scanned_script'));
18
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
19
+ }
20
+
21
+ public function register_options() {
22
+ register_setting( 'iubenda_script_scanner_form', 'iubenda_script_scanner_form' );
23
+ add_settings_section( 'iubenda_script_scanner_form', __( 'Detected Scripts', 'iubenda' ), array( $this, 'iubenda_consent_forms' ), 'iubenda_script_scanner_form' );
24
+ }
25
+
26
+ public function admin_menu_options() {
27
+ if ( iubenda()->options['cs']['menu_position'] === 'submenu' ) {
28
+ // Sub menu
29
+ add_submenu_page( 'iubenda', __( 'Cookie Solution', 'iubenda' ), __( 'Script Scanner', 'iubenda' ),
30
+ apply_filters( 'iubenda_cookie_law_cap', 'manage_options' ), 'iubenda&tab=test', array( $this, 'options_page' ) );
31
+
32
+ return;
33
+ }
34
+ add_submenu_page( 'iubenda', __( 'Cookie Solution', 'iubenda' ), __( 'Script Scanner', 'iubenda' ),
35
+ apply_filters( 'iubenda_cookie_law_cap', 'manage_options' ), 'iub-scanner', array( $this, 'options_page' ) );
36
+ }
37
+
38
+ /**
39
+ * Load admin options page.
40
+ *
41
+ * @return void
42
+ */
43
+ public function options_page() {
44
+ global $pagenow;
45
+
46
+ if ( ! current_user_can( apply_filters( 'iubenda_cookie_law_cap', 'manage_options' ) ) ) {
47
+ wp_die( __( "You don't have permission to access this page.", 'iubenda' ) );
48
+ }
49
+
50
+ // get redirect url
51
+ // $redirect_to = $this->get_redirect_to_url( $tab_key );
52
+
53
+ ?>
54
+ <div class="wrap">
55
+ <?php
56
+ $this->plugin_intro_header( );
57
+
58
+ // render custom notices
59
+ $this->print_notices();
60
+ ?>
61
+
62
+ <h2 style="display: none;"></h2>
63
+ <h2 class="nav-tab-wrapper iubenda-tab-wrapper">
64
+ <?php foreach (
65
+ array(
66
+ '' => 'Cookie Solution',
67
+ 'cons' => 'Consent Solution',
68
+ ) as $key => $name
69
+ ): ?>
70
+ <a class="nav-tab"
71
+ href="<?php echo esc_url( add_query_arg( $key ? array( 'tab' => $key ) : array(), iubenda()->base_url ) ); ?>"><?php _e( $name, 'iubenda' ); ?></a>
72
+ <?php endforeach; ?>
73
+ <a class="nav-tab nav-tab-active"
74
+ href="<?php echo esc_url( add_query_arg( array( 'page' => 'iub-scanner' ), iubenda()->base_url ) ); ?>"><?php _e( 'Script scanner', 'iubenda' ); ?></a>
75
+
76
+ </h2>
77
+
78
+ <div id="iubenda-settings">
79
+ <form id="iubenda-tabs" action="options.php" method="post">
80
+
81
+ <?php
82
+ // settings_fields( $this->tabs[ $tab_key ]['key'] );
83
+ do_settings_sections( 'iubenda_script_scanner_form' );
84
+ ?>
85
+
86
+ </form>
87
+
88
+ </div>
89
+ <div class="clear"></div>
90
+ </div>
91
+ <?php
92
+ }
93
+
94
+ /**
95
+ * @param string $tab_key
96
+ *
97
+ * @return string
98
+ */
99
+ private function get_redirect_to_url( $tab_key ) {
100
+ global $pagenow;
101
+ if ( iubenda()->options['cs']['menu_position'] === 'submenu' && $pagenow === 'admin.php' ) {
102
+ // sub menu
103
+ return admin_url( 'options-general.php?page=iubenda&tab=' . $tab_key );
104
+ }
105
+
106
+ // top menu
107
+ return admin_url( 'admin.php?page=iubenda&tab=' . $tab_key );
108
+ }
109
+
110
+ protected function plugin_intro_header( ) { ?>
111
+ <div id="iubenda-header">
112
+ <?php
113
+ echo '
114
+ <a class="iubenda-link" href="http://iubenda.com" title="iubenda" title="_blank">
115
+ <img id="iubenda-logo" alt="iubenda logo" width="300" height="90" src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IiB2aWV3Qm94PSIwIDAgNjM3LjggMjgzLjUiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDYzNy44IDI4My41OyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+PHN0eWxlIHR5cGU9InRleHQvY3NzIj4uc3Qwe2ZpbGw6IzFDQzY5MTt9LnN0MXtmaWxsOiM1MTUyNTQ7fTwvc3R5bGU+PHBhdGggY2xhc3M9InN0MCIgZD0iTTE3OC45L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MC41LTAuNC0wLjktMC45LTAuOXMtMC45LTAuNC0wLjktMC45di0xLjJjMC0xLjIsMC45LTIuMSwyLjEtMi4xaDUuNkMyMjkuNCwxMzIsMjMxLjEsMTMzLjcsMjMxLjEsMTM1LjkiLz48cGF0aCBjbGFzcz0ic3QxIiBkPSJNMjI2LjMsMTEwLjhjMy4zLDAsNiwyLjcsNiw1LjljMCwzLjMtMi43LDUuOS02LDUuOXMtNi0yLjctNi01LjlDMjIwLjMsMTEzLjUsMjIzLDExMC44LDIyNi4zLDExMC44Ii8+PC9zdmc+"/>
116
+ </a>';
117
+
118
+ ?>
119
+ </div>
120
+ <?php
121
+ }
122
+
123
+ public function iubenda_consent_forms() {
124
+ echo '
125
+ <p class="description">' . __( 'This section lists all detected scripts after scanning the current website.', 'iubenda' ) . '</p>';
126
+
127
+ // list screen
128
+ if ( ! class_exists( 'WP_List_Table' ) )
129
+ include_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
130
+
131
+ include_once( IUBENDA_PLUGIN_PATH . '/includes/script-list-table.php' );
132
+
133
+ $list_table = new iubenda_List_Table_Scripts();
134
+
135
+ echo '
136
+ <div id="iubenda-consent-forms">';
137
+ $list_table->views();
138
+ $list_table->prepare_items();
139
+ $list_table->display();
140
+
141
+ echo '
142
+ </div>';
143
+ }
144
+
145
+ public function toggle_scanned_script() {
146
+ // if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'toggle_scanned_script' ) ) {
147
+ // exit( 'Something went wrong, please try again later.' );
148
+ // }
149
+
150
+ $item = $_POST['item'];
151
+ $is_checked = $_POST['checked'];
152
+ $scripts = get_option( 'iub_active_scanned_scripts', array() );
153
+
154
+ if ( $is_checked ) {
155
+ $scripts[ $item['name'] ] = $item;
156
+ } elseif ( ! $is_checked && isset( $scripts[ $item['name'] ] ) ) {
157
+ unset($scripts[ $item['name'] ]);
158
+ }
159
+
160
+ update_option('iub_active_scanned_scripts', $scripts);
161
+ die(json_encode($scripts));
162
+ }
163
+
164
+ }
includes/settings.php CHANGED
@@ -192,9 +192,9 @@ class iubenda_Settings {
192
  * @return void
193
  */
194
  public function admin_enqueue_scripts( $page ) {
195
- wp_enqueue_style( 'iubenda-admin', IUBENDA_PLUGIN_URL . '/css/admin.css' );
196
 
197
- if ( ! in_array( $page, array( 'toplevel_page_iubenda', 'settings_page_iubenda' ) ) )
198
  return;
199
 
200
  wp_enqueue_script(
@@ -492,7 +492,6 @@ class iubenda_Settings {
492
  'iubenda_parse' => 'parse',
493
  'skip_parsing' => 'skip_parsing',
494
  'iubenda_ctype' => 'ctype',
495
- 'iubenda_parse' => 'parse',
496
  'parser_engine' => 'parser_engine',
497
  'iubenda_output_feed' => 'output_feed',
498
  'iubenda-code-default' => 'code_default',
@@ -542,7 +541,9 @@ class iubenda_Settings {
542
  }
543
 
544
  $tab_key = ! empty( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : 'cs';
545
-
 
 
546
  // get redirect url
547
  if ( iubenda()->options['cs']['menu_position'] === 'submenu' && $pagenow === 'admin.php' ) {
548
  // sub menu
@@ -648,6 +649,7 @@ class iubenda_Settings {
648
  <h2 class="nav-tab-wrapper iubenda-tab-wrapper">
649
  <a class="nav-tab<?php echo $tab_key == 'cs' ? ' nav-tab-active' : ''; ?>" href="<?php echo esc_url( iubenda()->base_url ); ?>"><?php _e( 'Cookie Solution', 'iubenda' ); ?></a>
650
  <a class="nav-tab<?php echo $tab_key == 'cons' ? ' nav-tab-active' : ''; ?>" href="<?php echo esc_url( add_query_arg( array( 'tab' => 'cons' ), iubenda()->base_url ) ); ?>"><?php _e( 'Consent Solution', 'iubenda' ); ?></a>
 
651
  </h2>
652
 
653
  <div id="iubenda-settings">
192
  * @return void
193
  */
194
  public function admin_enqueue_scripts( $page ) {
195
+ wp_enqueue_style( 'iubenda-admin', IUBENDA_PLUGIN_URL . '/css/admin.css' );
196
 
197
+ if ( ! in_array( $page, array( 'toplevel_page_iubenda', 'settings_page_iubenda' ,'iubenda_page_iub-scanner' ) ) )
198
  return;
199
 
200
  wp_enqueue_script(
492
  'iubenda_parse' => 'parse',
493
  'skip_parsing' => 'skip_parsing',
494
  'iubenda_ctype' => 'ctype',
 
495
  'parser_engine' => 'parser_engine',
496
  'iubenda_output_feed' => 'output_feed',
497
  'iubenda-code-default' => 'code_default',
541
  }
542
 
543
  $tab_key = ! empty( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : 'cs';
544
+ if('test' == $tab_key){
545
+ return;
546
+ }
547
  // get redirect url
548
  if ( iubenda()->options['cs']['menu_position'] === 'submenu' && $pagenow === 'admin.php' ) {
549
  // sub menu
649
  <h2 class="nav-tab-wrapper iubenda-tab-wrapper">
650
  <a class="nav-tab<?php echo $tab_key == 'cs' ? ' nav-tab-active' : ''; ?>" href="<?php echo esc_url( iubenda()->base_url ); ?>"><?php _e( 'Cookie Solution', 'iubenda' ); ?></a>
651
  <a class="nav-tab<?php echo $tab_key == 'cons' ? ' nav-tab-active' : ''; ?>" href="<?php echo esc_url( add_query_arg( array( 'tab' => 'cons' ), iubenda()->base_url ) ); ?>"><?php _e( 'Consent Solution', 'iubenda' ); ?></a>
652
+ <a class="nav-tab<?php echo $tab_key == 'test' ? ' nav-tab-active' : ''; ?>" href="<?php echo esc_url( add_query_arg( array( 'page' => 'iub-scanner' ), iubenda()->base_url ) ); ?>"><?php _e( 'Script Scanner', 'iubenda' ); ?></a>
653
  </h2>
654
 
655
  <div id="iubenda-settings">
iubenda-cookie-class/iubenda.class.php CHANGED
@@ -457,6 +457,35 @@ class iubendaParser {
457
  return $js;
458
  }
459
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
460
  /**
461
  * Parse automatically all the scripts in the page and converts it in text/plain
462
  * if src or the whole output has inside one of the elements in $auto_script_tags array
457
  return $js;
458
  }
459
 
460
+ public function get_scripts_from_html( $html ) {
461
+ // create new DOM document
462
+ $document = new DOMDocument();
463
+ libxml_use_internal_errors(true);
464
+ $document->formatOutput = true;
465
+ $document->preserveWhiteSpace = false;
466
+ $document->loadHTML( $html );
467
+ $scripts = $document->getElementsByTagName( 'script' );
468
+ $data = array();
469
+ // any scripts?
470
+ if ( ! empty( $scripts ) && is_object( $scripts ) ) {
471
+ foreach ( $scripts as $script ) {
472
+ $src = $script->getAttribute( 'src' );
473
+ $script_class = trim( $script->getAttribute( 'class' ) );
474
+
475
+ // add script as detected
476
+ if ( ! empty( $src ) ) {
477
+ $data[] = $src;
478
+ }
479
+
480
+ // add inline script as detected
481
+ if ( ! empty( $script->nodeValue ) ) {
482
+ $data[] = $script->nodeValue;
483
+ }
484
+ }
485
+ }
486
+
487
+ return $data;
488
+ }
489
  /**
490
  * Parse automatically all the scripts in the page and converts it in text/plain
491
  * if src or the whole output has inside one of the elements in $auto_script_tags array
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.5.1
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.5.1
36
  */
37
  class iubenda {
38
 
@@ -62,7 +62,7 @@ class iubenda {
62
  )
63
  );
64
  public $base_url;
65
- public $version = '2.5.1';
66
  public $activation = array(
67
  'update_version' => 0,
68
  'update_notice' => true,
@@ -109,6 +109,7 @@ class iubenda {
109
  self::$instance->AMP = new iubenda_AMP();
110
  self::$instance->forms = new iubenda_Forms();
111
  self::$instance->settings = new iubenda_Settings();
 
112
  }
113
 
114
  return self::$instance;
@@ -187,6 +188,7 @@ class iubenda {
187
  */
188
  private function includes() {
189
  include_once( IUBENDA_PLUGIN_PATH . 'includes/settings.php' );
 
190
  include_once( IUBENDA_PLUGIN_PATH . 'includes/forms.php' );
191
  include_once( IUBENDA_PLUGIN_PATH . 'includes/amp.php' );
192
  }
@@ -526,6 +528,12 @@ class iubenda {
526
  if ( class_exists( 'Jetpack' ) )
527
  $this->options['cs']['custom_scripts']['stats.wp.com'] = 5;
528
 
 
 
 
 
 
 
529
  $startime = microtime( true );
530
  $output = apply_filters( 'iubenda_initial_output', $output );
531
 
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.5.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.5.0
36
  */
37
  class iubenda {
38
 
62
  )
63
  );
64
  public $base_url;
65
+ public $version = '2.5.0';
66
  public $activation = array(
67
  'update_version' => 0,
68
  'update_notice' => true,
109
  self::$instance->AMP = new iubenda_AMP();
110
  self::$instance->forms = new iubenda_Forms();
111
  self::$instance->settings = new iubenda_Settings();
112
+ self::$instance->script_scanner = new ScriptScanner();
113
  }
114
 
115
  return self::$instance;
188
  */
189
  private function includes() {
190
  include_once( IUBENDA_PLUGIN_PATH . 'includes/settings.php' );
191
+ include_once( IUBENDA_PLUGIN_PATH . 'includes/script-scanner.php' );
192
  include_once( IUBENDA_PLUGIN_PATH . 'includes/forms.php' );
193
  include_once( IUBENDA_PLUGIN_PATH . 'includes/amp.php' );
194
  }
528
  if ( class_exists( 'Jetpack' ) )
529
  $this->options['cs']['custom_scripts']['stats.wp.com'] = 5;
530
 
531
+
532
+ // Add additional scripts to custom
533
+ foreach ( get_option( 'iub_active_scanned_scripts', array() ) as $item ) {
534
+ $this->options['cs']['custom_scripts'][ $item['script'] ] = $item['purpose'];
535
+ }
536
+
537
  $startime = microtime( true );
538
  $output = apply_filters( 'iubenda_initial_output', $output );
539
 
js/admin.js CHANGED
@@ -277,6 +277,29 @@
277
  $( '#postbox-container-2' ).change();
278
  } );
279
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
  } );
281
 
282
  } )( jQuery );
277
  $( '#postbox-container-2' ).change();
278
  } );
279
 
280
+ $('.toggle-scanned-script-status').on('click', function (el) {
281
+ var is_checked = el.target.checked;
282
+ var item = JSON.parse(el.target.getAttribute('data-item'));
283
+ var admin_ajax_url = el.target.getAttribute('data-ajax-url');
284
+ var nonce = el.target.getAttribute('data-nonce');
285
+
286
+ $.ajax({
287
+ type : 'post',
288
+ dataType : 'json',
289
+ url : admin_ajax_url,
290
+ data : {action: "toggle_scanned_script", item : item, nonce: nonce, checked: is_checked ? 1 : 0},
291
+ success: function(response) {
292
+ console.info(response);
293
+ // if(response.type == "success") {
294
+ // jQuery("#vote_counter").html(response.vote_count)
295
+ // }
296
+ // else {
297
+ // alert("Your vote could not be added")
298
+ // }
299
+ }
300
+ })
301
+
302
+ });
303
  } );
304
 
305
  } )( jQuery );
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: cookies, cookie law, cookie policy, cookie banner, privacy policy, cookie
5
  Requires at least: 4.0
6
  Requires PHP: 5.2.4
7
  Tested up to: 5.7.0
8
- Stable tag: 2.5.1
9
  License: MIT License
10
  License URI: http://opensource.org/licenses/MIT
11
 
@@ -150,9 +150,6 @@ We will be very happy to receive feedback here: [Uservoice forum](https://suppor
150
 
151
  == Changelog ==
152
 
153
- = 2.5.1 =
154
- * Fix: Track the selected checkboxes into wpforms
155
-
156
  = 2.5.0 =
157
  * Integrate with Mailchimp to add it in woo-commerce checkout form.
158
  * Stop parsing scripts in Divi page builder
@@ -515,5 +512,6 @@ We will be very happy to receive feedback here: [Uservoice forum](https://suppor
515
 
516
  == Upgrade Notice ==
517
 
518
- = 2.5.1 =
519
- * Fix: Track the selected checkboxes into wpforms
 
5
  Requires at least: 4.0
6
  Requires PHP: 5.2.4
7
  Tested up to: 5.7.0
8
+ Stable tag: 2.5.0
9
  License: MIT License
10
  License URI: http://opensource.org/licenses/MIT
11
 
150
 
151
  == Changelog ==
152
 
 
 
 
153
  = 2.5.0 =
154
  * Integrate with Mailchimp to add it in woo-commerce checkout form.
155
  * Stop parsing scripts in Divi page builder
512
 
513
  == Upgrade Notice ==
514
 
515
+ = 2.5.0 =
516
+ * Integrate with Mailchimp to add it in woo-commerce checkout form.
517
+ * Stop parsing scripts in Divi page builder
scripts.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "purpose": 1,
4
+ "name": "Altervista Advertising",
5
+ "script": "ad.altervista.org"
6
+ },
7
+ {
8
+ "purpose": 5,
9
+ "name": "ComScore Analytics",
10
+ "script": "static.criteo.net"
11
+ },
12
+ {
13
+ "purpose": 2,
14
+ "name": "Tawk.to Widget",
15
+ "script": "embed.tawk.to"
16
+ }
17
+ ]