iubenda Cookie Solution for GDPR - Version 3.1.0

Version Description

  • Move plugin settings to a separate page
  • Add the ability to include PP and TC buttons for default WP
Download this release

Release Info

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

Code changes from version 3.0.10 to 3.1.0

assets/js/legal_block.js ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ( function ( blocks, editor, i18n, element, components, _, blockEditor ) {
2
+ var __ = i18n.__;
3
+ var el = element.createElement;
4
+ var RichText = blockEditor.RichText;
5
+ var useBlockProps = blockEditor.useBlockProps;
6
+
7
+ const iconEl = el('svg', {},
8
+ el('path', {
9
+ fill:"#1CC691" ,
10
+ d: "M 11.6671 0 c 3.1311 0 5.6675 2.5268 5.6675 5.6464 c 0 1.3892 -0.5031 2.6608 -1.3408 3.6454 L 17.1974 25.5634 H 6.4376 l 1.1666 -15.9874 A 5.6025 5.6025 90 0 1 6 5.6468 C 6 2.5268 8.5364 0 11.6671 0 z m 1.0762 11.8411 l -1.865 1.8653 v 7.38 h 1.865 V 11.8411 z M 11.6671 4.1886 c -0.7528 0 -1.3628 0.6142 -1.3628 1.3723 c 0 0.7576 0.61 1.372 1.3628 1.372 s 1.3631 -0.6142 1.3631 -1.372 c 0 -0.7582 -0.6104 -1.3723 -1.3631 -1.3723 z"
11
+ } )
12
+ );
13
+
14
+ blocks.registerBlockType( iub_block_js_vars.block_name, {
15
+ title: __('Iubenda legal block', 'iubenda'),
16
+ icon: iconEl,
17
+ category: 'layout',
18
+ attributes: {
19
+ title: {
20
+ type: 'string',
21
+ default: __('Legal', 'iubenda')
22
+ },
23
+ },
24
+ edit: function ( props ) {
25
+ var attributes = props.attributes;
26
+
27
+ return el(
28
+ 'div',
29
+ useBlockProps({ className: props.className }),
30
+ el( RichText, {
31
+ tagName: 'p',
32
+ placeholder: __('Iubenda legal block', 'iubenda'),
33
+ value: attributes.title,
34
+ onChange: function ( value ) {
35
+ props.setAttributes( { title: value } );
36
+ },
37
+ } ),
38
+ el( 'p', {}, '' ),
39
+ );
40
+ },
41
+ save: function ( props ) {
42
+ var attributes = props.attributes;
43
+
44
+ return el(
45
+ 'div',
46
+ useBlockProps.save( { className: props.className } ),
47
+ el( RichText.Content, {
48
+ tagName: 'p',
49
+ value: attributes.title,
50
+ } ),
51
+ el( 'p', {}, '['+iub_block_js_vars.iub_legal_block_shortcode+']' ),
52
+ );
53
+ },
54
+ } );
55
+ } )(
56
+ window.wp.blocks,
57
+ window.wp.editor,
58
+ window.wp.i18n,
59
+ window.wp.element,
60
+ window.wp.components,
61
+ window._,
62
+ window.wp.blockEditor
63
+ );
64
+
includes/ProductHelper.php CHANGED
@@ -99,4 +99,39 @@ class ProductHelper
99
 
100
  return boolval(trim($iubenda_code));
101
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  }
99
 
100
  return boolval(trim($iubenda_code));
101
  }
102
+
103
+ /**
104
+ * Getting public id for current language if stored in database
105
+ * @return array|ArrayAccess|false|mixed
106
+ */
107
+ public function get_public_id_for_current_language(){
108
+ // Checking if there is no public id for current language
109
+ if ( iubenda()->multilang && ! empty( iubenda()->lang_current ) ) {
110
+ $lang_id = iubenda()->lang_current;
111
+ } else {
112
+ $lang_id = 'default';
113
+ }
114
+
115
+ return iub_array_get(iubenda()->options['global_options'], "public_ids.{$lang_id}", false) ?: false;
116
+ }
117
+
118
+ /**
119
+ * Check privacy policy and terms and condition services status and position and codes
120
+ *
121
+ * @return bool
122
+ */
123
+ public function check_pp_tc_status_and_position(){
124
+ $ppStatus = iub_array_get(iubenda()->settings->services, 'pp.status') == 'true';
125
+ $ppPosition = iub_array_get(iubenda()->options['pp'], 'button_position') == 'automatic';
126
+
127
+ $tcStatus = iub_array_get(iubenda()->settings->services, 'tc.status') == 'true';
128
+ $tcPosition = iub_array_get(iubenda()->options['tc'], 'button_position') == 'automatic';
129
+ $quickGeneratorService = new QuickGeneratorService();
130
+
131
+ if (!($ppStatus && $ppPosition && boolval($quickGeneratorService->pp_button())) && !($tcStatus && $tcPosition && boolval($quickGeneratorService->tc_button()))) {
132
+ return false;
133
+ }
134
+
135
+ return true;
136
+ }
137
  }
includes/QuickGeneratorService.php CHANGED
@@ -119,6 +119,9 @@ class QuickGeneratorService
119
 
120
  public function integrate_setup()
121
  {
 
 
 
122
  if(iub_array_get($_POST, 'cookie_law') == 'on'){
123
  // Saving CS data with CS function
124
  $this->cs_save_options();
@@ -233,6 +236,12 @@ class QuickGeneratorService
233
  if($iubenda_section_key == 'cs'){
234
  $this->cs_save_options(false);
235
  }
 
 
 
 
 
 
236
  else{
237
  $codes_statues = [];
238
  $global_options = iubenda()->options['global_options'];
@@ -266,7 +275,7 @@ class QuickGeneratorService
266
  if($iubenda_section_name == 'iubenda_privacy_policy_solution') {
267
  // Add a widget in the sidebar if the button is positioned automatically
268
  if('automatic' === iub_array_get($section_new_option, 'button_position')){
269
- do_action('iubenda_assign_widget_to_first_sidebar');
270
  }
271
 
272
  // Merge old old PP options with new options to update codes with new style
@@ -281,7 +290,7 @@ class QuickGeneratorService
281
  if($iubenda_section_name == 'iubenda_terms_conditions_solution') {
282
  // Add a widget in the sidebar if the button is positioned automatically
283
  if('automatic' === iub_array_get($section_new_option, 'button_position')){
284
- do_action('iubenda_assign_widget_to_first_sidebar');
285
  }
286
 
287
  // Update TC codes with new button style
@@ -380,12 +389,7 @@ class QuickGeneratorService
380
  $new_cs_option['parse'] = (bool)isset($new_cs_option['parse']);
381
  $new_cs_option['parser_engine'] = isset($new_cs_option['parser_engine']) && in_array($new_cs_option['parser_engine'], ['default', 'new']) ? $new_cs_option['parser_engine'] : iubenda()->defaults['cs']['parser_engine'];
382
  $new_cs_option['skip_parsing'] = (bool)isset($new_cs_option['skip_parsing']);
383
- $new_cs_option['ctype'] = (bool)isset($new_cs_option['ctype']);
384
- $new_cs_option['output_feed'] = (bool)isset($new_cs_option['output_feed']);
385
- $new_cs_option['output_post'] = (bool)isset($new_cs_option['output_post']);
386
- $new_cs_option['menu_position'] = isset($new_cs_option['menu_position']) && in_array($new_cs_option['menu_position'], ['topmenu', 'submenu']) ? $new_cs_option['menu_position'] : iubenda()->defaults['cs']['menu_position'];
387
  $new_cs_option['amp_support'] = iub_array_get($new_cs_option, 'amp_support', false) ?: false;
388
- $new_cs_option['deactivation'] = (bool)isset($new_cs_option['deactivation']);
389
  }
390
 
391
  if(isset($new_cs_option['custom_scripts'])){
@@ -542,6 +546,27 @@ class QuickGeneratorService
542
  update_option( 'iubenda_global_options', $global_options );
543
  }
544
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
545
  /**
546
  * saving Iubenda privacy policy solution options
547
  */
@@ -574,7 +599,7 @@ class QuickGeneratorService
574
 
575
  // Add a widget in the sidebar if the button is positioned automatically
576
  if('automatic' === iub_array_get($_POST, 'iubenda_privacy_policy_solution.button_position')){
577
- do_action('iubenda_assign_widget_to_first_sidebar');
578
  }
579
 
580
  // Set the version of PP service as Simplified
119
 
120
  public function integrate_setup()
121
  {
122
+ // Saving iubenda plugin settings
123
+ $this->plugin_settings_save_options();
124
+
125
  if(iub_array_get($_POST, 'cookie_law') == 'on'){
126
  // Saving CS data with CS function
127
  $this->cs_save_options();
236
  if($iubenda_section_key == 'cs'){
237
  $this->cs_save_options(false);
238
  }
239
+
240
+ // Elseif section == Plugin-settings save by plugin settings function
241
+ elseif($iubenda_section_key == 'plugin-settings'){
242
+ $this->plugin_settings_save_options(false);
243
+ }
244
+
245
  else{
246
  $codes_statues = [];
247
  $global_options = iubenda()->options['global_options'];
275
  if($iubenda_section_name == 'iubenda_privacy_policy_solution') {
276
  // Add a widget in the sidebar if the button is positioned automatically
277
  if('automatic' === iub_array_get($section_new_option, 'button_position')){
278
+ iubenda()->assign_legal_block_or_widget();
279
  }
280
 
281
  // Merge old old PP options with new options to update codes with new style
290
  if($iubenda_section_name == 'iubenda_terms_conditions_solution') {
291
  // Add a widget in the sidebar if the button is positioned automatically
292
  if('automatic' === iub_array_get($section_new_option, 'button_position')){
293
+ iubenda()->assign_legal_block_or_widget();
294
  }
295
 
296
  // Update TC codes with new button style
389
  $new_cs_option['parse'] = (bool)isset($new_cs_option['parse']);
390
  $new_cs_option['parser_engine'] = isset($new_cs_option['parser_engine']) && in_array($new_cs_option['parser_engine'], ['default', 'new']) ? $new_cs_option['parser_engine'] : iubenda()->defaults['cs']['parser_engine'];
391
  $new_cs_option['skip_parsing'] = (bool)isset($new_cs_option['skip_parsing']);
 
 
 
 
392
  $new_cs_option['amp_support'] = iub_array_get($new_cs_option, 'amp_support', false) ?: false;
 
393
  }
394
 
395
  if(isset($new_cs_option['custom_scripts'])){
546
  update_option( 'iubenda_global_options', $global_options );
547
  }
548
 
549
+ /**
550
+ * Saving iubenda plugin settings
551
+ * @param bool $default_options
552
+ */
553
+ private function plugin_settings_save_options($default_options = true)
554
+ {
555
+ $new_options = iub_array_get($_POST, 'iubenda_plugin_settings');
556
+
557
+ if (!$default_options) {
558
+ $new_options['ctype'] = (bool)isset($new_options['ctype']);
559
+ $new_options['output_feed'] = (bool)isset($new_options['output_feed']);
560
+ $new_options['output_post'] = (bool)isset($new_options['output_post']);
561
+ $new_options['menu_position'] = (bool)isset($new_options['menu_position']) ? $new_options['menu_position'] : iubenda()->defaults['cs']['menu_position'];
562
+ $new_options['deactivation'] = (bool)isset($new_options['deactivation']);
563
+ }
564
+
565
+ $old_cs_options = $this->stripslashes_deep(iubenda()->options['cs']);
566
+ $new_cs_option = array_merge($old_cs_options, $new_options);
567
+ update_option('iubenda_cookie_law_solution', $new_cs_option);
568
+ }
569
+
570
  /**
571
  * saving Iubenda privacy policy solution options
572
  */
599
 
600
  // Add a widget in the sidebar if the button is positioned automatically
601
  if('automatic' === iub_array_get($_POST, 'iubenda_privacy_policy_solution.button_position')){
602
+ iubenda()->assign_legal_block_or_widget();
603
  }
604
 
605
  // Set the version of PP service as Simplified
includes/block/IubendaLegalBlock.php ADDED
@@ -0,0 +1,379 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class IubendaLegalBlock
5
+ {
6
+ const IUB_LEGAL_BLOCK_NAME = 'iubenda/legal-block'; // IUB legal block Name
7
+ const IUB_LEGAL_BLOCK_SHORTCODE = 'iub-wp-block-buttons'; // IUB legal block Shortcode
8
+
9
+ /**
10
+ * IubendaLegalBlock constructor.
11
+ */
12
+ public function __construct()
13
+ {
14
+ add_action('iubenda_attach_block_in_footer', [$this, 'attach_legal_block_into_footer']);
15
+
16
+ // Attach IUB legal block into WP blocks area
17
+ add_action('init', [$this, 'attach_legal_block_into_block_area'], 10, 0);
18
+ }
19
+
20
+ /**
21
+ * Attach iubenda legal block in footer
22
+ */
23
+ public function attach_legal_block_into_footer()
24
+ {
25
+ // if current theme doesn't supports blocks -> return
26
+ if (!$this->check_current_theme_supports_blocks()) {
27
+ return;
28
+ }
29
+
30
+ // Check if IUB short code exist in footer
31
+ if ($this->check_iub_block_shortcode_exists_in_the_footer()) {
32
+ return;
33
+ }
34
+
35
+ $this->force_append_legal_block_in_footer();
36
+ }
37
+
38
+ /**
39
+ * Detach iubenda legal block from footer
40
+ */
41
+ public function detach_legal_block_from_footer()
42
+ {
43
+ // if current theme doesn't supports blocks -> return
44
+ if (!$this->check_current_theme_supports_blocks()) {
45
+ return;
46
+ }
47
+
48
+ // Check if IUB short code exist in footer
49
+ if ($this->check_iub_block_shortcode_exists_in_the_footer()) {
50
+ $this->force_detach_legal_block_from_footer();
51
+ return;
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Attach iubenda legal block in WP blocks area
57
+ */
58
+ public function attach_legal_block_into_block_area()
59
+ {
60
+ add_shortcode(static::IUB_LEGAL_BLOCK_SHORTCODE, [$this, 'render_iub_legal_block']);
61
+
62
+ // Register IUB js block
63
+ wp_register_script('iubenda-block-editor', IUBENDA_PLUGIN_URL . '/assets/js/legal_block.js', ['wp-blocks', 'wp-editor'], iubenda()->version);
64
+ register_block_type(static::IUB_LEGAL_BLOCK_NAME, ['editor_script' => 'iubenda-block-editor',]);
65
+
66
+ // Send iub vars from backend to JS file
67
+ wp_localize_script('iubenda-block-editor', 'iub_block_js_vars', ['block_name' => 'iubenda/legal-block', 'iub_legal_block_shortcode' => static::IUB_LEGAL_BLOCK_SHORTCODE]);
68
+
69
+ // Enqueued script with localized data.
70
+ wp_enqueue_script('iubenda-block-editor');
71
+
72
+ // Force attach legal block into WP_Block_Patterns as WP default footer
73
+ $this->change_pre_registered_default_footer_content(false);
74
+ }
75
+
76
+ /**
77
+ * Render iubenda legal block and apply filters
78
+ * @return mixed
79
+ */
80
+ public function render_iub_legal_block()
81
+ {
82
+ $html = '';
83
+ $html = apply_filters('before_iub_legal_block_section', $html);
84
+ $html .= '<section>' . $this->iub_legal_block_html($html) . '</section>';
85
+ $html = apply_filters('after_iub_legal_block_section', $html);
86
+
87
+ return $html;
88
+ }
89
+
90
+ /**
91
+ * Check if the current theme support WP blocks or not
92
+ * @return bool
93
+ */
94
+ public function check_current_theme_supports_blocks()
95
+ {
96
+ // Condition if there is no sidebar and the activated theme is working by WP blocks
97
+ global $wp_registered_sidebars;
98
+
99
+ if (!boolval(iub_array_get($wp_registered_sidebars, 'sidebar-1'))) {
100
+ return true;
101
+ }
102
+
103
+ return false;
104
+ }
105
+
106
+ /**
107
+ * Iubenda legal block html
108
+ * @param $html
109
+ * @return mixed|string
110
+ */
111
+ private function iub_legal_block_html($html)
112
+ {
113
+ $quick_generator_service = new QuickGeneratorService();
114
+
115
+ $pp_status = iub_array_get(iubenda()->settings->services, 'pp.status') == 'true';
116
+ $pp_position = iub_array_get(iubenda()->options['pp'], 'button_position') == 'automatic';
117
+ $tc_status = iub_array_get(iubenda()->settings->services, 'tc.status') == 'true';
118
+ $tc_position = iub_array_get(iubenda()->options['tc'], 'button_position') == 'automatic';
119
+
120
+ if ($pp_status && $pp_position) {
121
+ $html .= $quick_generator_service->pp_button();
122
+ }
123
+
124
+ if (($pp_status && $pp_position) && ($tc_status && $tc_position)) {
125
+ $html .= '<br>';
126
+ }
127
+
128
+ if (($tc_status == 'true') && ($tc_position == 'automatic')) {
129
+ $html .= $quick_generator_service->tc_button();
130
+ }
131
+
132
+ return $html;
133
+ }
134
+
135
+ /**
136
+ * Get footer post from database
137
+ * @return mixed|null
138
+ */
139
+ private function get_footer_from_database()
140
+ {
141
+ // Default arguments
142
+ $args = [
143
+ 'post_type' => 'wp_template_part',
144
+ 'post_status' => 'publish',
145
+ 'tax_query' => [
146
+ [
147
+ 'taxonomy' => 'wp_theme',
148
+ 'field' => 'slug',
149
+ 'terms' => [ get_stylesheet() ],
150
+ ],
151
+ ],
152
+ 'posts_per_page' => 1,
153
+ 'no_found_rows' => true,
154
+ ];
155
+
156
+ // Search for footer in database
157
+ $args['name'] = 'footer';
158
+
159
+ // Run WP Query with new args
160
+ $footer_query = new WP_Query($args);
161
+ $footer = $footer_query->have_posts() ? $footer_query->next_post() : null;
162
+
163
+ // Footer exist in database
164
+ if ($footer) {
165
+ return $footer;
166
+ }
167
+
168
+ // Search if it is inserted as a default footer in the database
169
+ $args['name'] = 'default-footer';
170
+
171
+ // Run WP Query with new args
172
+ $footer_query = new WP_Query($args);
173
+ $footer = $footer_query->have_posts() ? $footer_query->next_post() : null;
174
+
175
+ return $footer;
176
+ }
177
+
178
+ /**
179
+ * Check if IUB short code exist in footer
180
+ * @return bool
181
+ */
182
+ private function check_iub_block_shortcode_exists_in_the_footer()
183
+ {
184
+ $footer = $this->get_footer_from_database();
185
+
186
+ if ($footer && strpos($footer->post_content, '[iub-wp-block-buttons]') !== false) {
187
+ return true;
188
+ }
189
+
190
+ return false;
191
+ }
192
+
193
+ /**
194
+ * Force append IUB legal block in footer
195
+ */
196
+ private function force_append_legal_block_in_footer()
197
+ {
198
+ $footer = $this->get_footer_from_database();
199
+
200
+ if ($footer) {
201
+ $footer->post_content = $this->insert_iub_block_shortcode_into_footer_by_dom($footer->post_content);
202
+
203
+ $this->update_the_footer_into_database($footer);
204
+ }
205
+
206
+ // There is no footer stored in database then
207
+ // Attach legal block into WP_Block_Patterns as WP default footer and insert this footer into database
208
+ $this->change_pre_registered_default_footer_content();
209
+ }
210
+
211
+ /**
212
+ * Insert Legal block into WP content by php DOMDocument
213
+ *
214
+ * @param $footer_content
215
+ * @return false|string
216
+ */
217
+ private function insert_iub_block_shortcode_into_footer_by_dom($footer_content)
218
+ {
219
+ $dom = new DOMDocument();
220
+ $previous_value = libxml_use_internal_errors(TRUE);
221
+ $dom->loadHTML((string)$footer_content, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
222
+ libxml_clear_errors();
223
+ libxml_use_internal_errors($previous_value);
224
+
225
+ $target_div = $dom->getElementsByTagName('div')->item(1);
226
+
227
+ if(!$target_div){
228
+ return '';
229
+ }
230
+
231
+ // insert End of Iubenda legal block before start
232
+ $template = $dom->createDocumentFragment();
233
+ $template->appendXML(' <!-- /wp:'. static::IUB_LEGAL_BLOCK_NAME .' --> ');
234
+ $target_div->insertBefore($template, $target_div->firstChild);
235
+
236
+ // Create container div with class 'wp-block-iubenda-legal-block'
237
+ $div = $dom->createElement("div");
238
+ $div->setAttribute("class", "wp-block-iubenda-legal-block");
239
+
240
+ // Append the block title
241
+ $div->appendChild($dom->createElement('p', __('Legal', 'iubenda')));
242
+
243
+ // Append the block content
244
+ $div->appendChild($dom->createElement('p', '[iub-wp-block-buttons]'));
245
+
246
+ // Insert the block into the footer
247
+ $target_div->insertBefore($div, $target_div->firstChild);
248
+
249
+ // Append Start of Iubenda legal block
250
+ $template = $dom->createDocumentFragment();
251
+ $template->appendXML(' <!-- wp:'. static::IUB_LEGAL_BLOCK_NAME .' --> ');
252
+ $target_div->insertBefore($template, $target_div->firstChild);
253
+
254
+ return $dom->saveHTML();
255
+ }
256
+
257
+ /**
258
+ * Remove Legal block from WP content
259
+ *
260
+ * @param $footer_content
261
+ * @return false|string
262
+ */
263
+ private function remove_iub_block_shortcode_from_footer($footer_content)
264
+ {
265
+ $start_of_iub_legal_block = '<!-- wp:'. static::IUB_LEGAL_BLOCK_NAME .' -->';
266
+ $end_of_iub_legal_block = '<!-- /wp:'. static::IUB_LEGAL_BLOCK_NAME .' -->';
267
+
268
+ return $this->iub_delete_in_between($start_of_iub_legal_block, $end_of_iub_legal_block, $footer_content);
269
+ }
270
+
271
+ /**
272
+ * Update the current footer
273
+ *
274
+ * @param $footer
275
+ */
276
+ private function update_the_footer_into_database($footer)
277
+ {
278
+ return wp_update_post($footer);
279
+ }
280
+
281
+ /**
282
+ * Attach legal block into WP_Block_Patterns as WP default footer
283
+ * if $insert_into_database is true insert default footer into database
284
+ *
285
+ * @param bool $insert_into_database
286
+ * @return void
287
+ */
288
+ private function change_pre_registered_default_footer_content($insert_into_database = true)
289
+ {
290
+ $public_id = (new ProductHelper())->get_public_id_for_current_language();
291
+
292
+ // Return false if there is no public id for current language
293
+ if (!($public_id)) {
294
+ return;
295
+ }
296
+
297
+ // Check for PP & TC service status and codes
298
+ if (!(new ProductHelper())->check_pp_tc_status_and_position()) {
299
+ return;
300
+ }
301
+
302
+ $block_registry = WP_Block_Patterns_Registry::get_instance();
303
+
304
+ foreach ( $block_registry->get_all_registered() as $block) {
305
+ $block_name = iub_array_get($block, 'name') ?: null;
306
+
307
+ if (strpos($block_name, 'footer-default') !== false) {
308
+ // Unregister default footer
309
+ $block_registry->unregister(iub_array_get($block, 'name'));
310
+
311
+ // Attach Iubenda legal block in footer content
312
+ $block['content'] = $this->insert_iub_block_shortcode_into_footer_by_dom(iub_array_get($block, 'content'));
313
+
314
+ // Register footer after attached Iubenda legal block on it
315
+ $block_registry->register(iub_array_get($block, 'name'), $block);
316
+
317
+ if ($insert_into_database) {
318
+ // Insert the footer into database
319
+ $this->insert_default_footer_into_database($block);
320
+ }
321
+ }
322
+ }
323
+ }
324
+
325
+ /**
326
+ * Insert default footer into database
327
+ *
328
+ * @param $block
329
+ * @return int|WP_Error
330
+ */
331
+ private function insert_default_footer_into_database($block)
332
+ {
333
+ // taxonomies
334
+ $taxonomies = [
335
+ 'wp_template_part_area' => 'footer',
336
+ 'wp_theme' => get_stylesheet(), // Current active theme slug
337
+ ];
338
+
339
+ // New footer data
340
+ $footer = [
341
+ 'post_title' => 'Footer',
342
+ 'post_content' => $block['content'],
343
+ 'post_status' => 'publish',
344
+ 'post_author' => 1,
345
+ 'post_type' => 'wp_template_part',
346
+ 'post_category' => [ 'footer' ],
347
+ 'tax_input' => $taxonomies
348
+ ];
349
+
350
+ // Insert the new footer into the database
351
+ wp_insert_post($footer);
352
+ }
353
+
354
+ /**
355
+ * Force detach IUB legal block from footer
356
+ */
357
+ private function force_detach_legal_block_from_footer()
358
+ {
359
+ $footer = $this->get_footer_from_database();
360
+
361
+ if ($footer) {
362
+ $footer->post_content = $this->remove_iub_block_shortcode_from_footer($footer->post_content);
363
+
364
+ $this->update_the_footer_into_database($footer);
365
+ }
366
+ }
367
+
368
+ private function iub_delete_in_between($beginning, $end, $string) {
369
+ $beginning_pos = strpos($string, $beginning);
370
+ $end_pos = strpos($string, $end);
371
+ if ($beginning_pos === false || $end_pos === false) {
372
+ return $string;
373
+ }
374
+
375
+ $text_to_delete = substr($string, $beginning_pos, ($end_pos + strlen($end)) - $beginning_pos);
376
+
377
+ return $this->iub_delete_in_between($beginning, $end, str_replace($text_to_delete, '', $string)); // recursion to ensure occurrences are removed
378
+ }
379
+ }
includes/settings.php CHANGED
@@ -63,7 +63,7 @@ class iubenda_Settings {
63
  add_shortcode( 'iub-tc-button', array( new QuickGeneratorService(), 'tc_button_shortcode' ) );
64
  add_shortcode( 'iub-pp-button', array( new QuickGeneratorService(), 'pp_button_shortcode' ) );
65
 
66
- }
67
 
68
  /**
69
  * Load default settings.
@@ -364,6 +364,10 @@ class iubenda_Settings {
364
  $view = iub_array_get($_GET, 'view', $default);
365
 
366
  switch ($view) {
 
 
 
 
367
  case "integrate-setup":
368
  require_once IUBENDA_PLUGIN_PATH . 'views/integrate-setup.php';
369
  break;
@@ -1269,7 +1273,7 @@ class iubenda_Settings {
1269
  $product_option['button_position'] = 'automatic';
1270
 
1271
  // Add a widget in the sidebar
1272
- do_action('iubenda_assign_widget_to_first_sidebar');
1273
  }
1274
 
1275
  $product_option["code_{$lang_id}"] = stripslashes($code);
@@ -1280,7 +1284,7 @@ class iubenda_Settings {
1280
 
1281
  if (in_array($product_key, ['pp', 'tc'])) {
1282
  // Add a widget in the sidebar if the button is positioned automatically
1283
- do_action('iubenda_assign_widget_to_first_sidebar');
1284
  }
1285
 
1286
  //add version if Iubenda privacy policy solution activated
@@ -1360,7 +1364,7 @@ class iubenda_Settings {
1360
  $product_option['button_position'] = 'automatic';
1361
 
1362
  // Add a widget in the sidebar
1363
- do_action('iubenda_assign_widget_to_first_sidebar');
1364
  }
1365
 
1366
  $product_option["code_{$lang_id}"] = stripslashes($code);
@@ -1371,7 +1375,7 @@ class iubenda_Settings {
1371
 
1372
  if (in_array($product_key, ['pp', 'tc'])) {
1373
  // Add a widget in the sidebar if the button is positioned automatically
1374
- do_action('iubenda_assign_widget_to_first_sidebar');
1375
  }
1376
 
1377
  //add version if Iubenda privacy policy solution activated
63
  add_shortcode( 'iub-tc-button', array( new QuickGeneratorService(), 'tc_button_shortcode' ) );
64
  add_shortcode( 'iub-pp-button', array( new QuickGeneratorService(), 'pp_button_shortcode' ) );
65
 
66
+ }
67
 
68
  /**
69
  * Load default settings.
364
  $view = iub_array_get($_GET, 'view', $default);
365
 
366
  switch ($view) {
367
+ case "plugin-settings":
368
+ $pageLabels = [['title' => __('Plugin settings', 'iubenda')]];
369
+ require_once IUBENDA_PLUGIN_PATH . 'views/plugin-settings.php';
370
+ break;
371
  case "integrate-setup":
372
  require_once IUBENDA_PLUGIN_PATH . 'views/integrate-setup.php';
373
  break;
1273
  $product_option['button_position'] = 'automatic';
1274
 
1275
  // Add a widget in the sidebar
1276
+ iubenda()->assign_legal_block_or_widget();
1277
  }
1278
 
1279
  $product_option["code_{$lang_id}"] = stripslashes($code);
1284
 
1285
  if (in_array($product_key, ['pp', 'tc'])) {
1286
  // Add a widget in the sidebar if the button is positioned automatically
1287
+ iubenda()->assign_legal_block_or_widget();
1288
  }
1289
 
1290
  //add version if Iubenda privacy policy solution activated
1364
  $product_option['button_position'] = 'automatic';
1365
 
1366
  // Add a widget in the sidebar
1367
+ iubenda()->assign_legal_block_or_widget();
1368
  }
1369
 
1370
  $product_option["code_{$lang_id}"] = stripslashes($code);
1375
 
1376
  if (in_array($product_key, ['pp', 'tc'])) {
1377
  // Add a widget in the sidebar if the button is positioned automatically
1378
+ iubenda()->assign_legal_block_or_widget();
1379
  }
1380
 
1381
  //add version if Iubenda privacy policy solution activated
includes/widget/IubendaLegalWidget.php CHANGED
@@ -218,6 +218,21 @@ class IubendaLegalWidget extends WP_Widget
218
  public function register_widget() {
219
  register_widget(__CLASS__);
220
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
221
  }
222
 
223
 
218
  public function register_widget() {
219
  register_widget(__CLASS__);
220
  }
221
+
222
+ /**
223
+ * Check current theme supports widget
224
+ */
225
+ public function check_current_theme_supports_widget()
226
+ {
227
+ global $wp_registered_sidebars;
228
+
229
+ // If sidebar-1 registered and activated
230
+ if (iub_array_get($wp_registered_sidebars, 'sidebar-1')) {
231
+ return true;
232
+ }
233
+
234
+ return false;
235
+ }
236
  }
237
 
238
 
iubenda_cookie_solution.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Cookie and Consent Solution for the GDPR & ePrivacy
4
  Plugin URI: https://www.iubenda.com
5
  Description: An All-in-One approach developed by iubenda, which includes functionalities of two powerful solutions that help to make your website GDPR and ePrivacy compliant.
6
- Version: 3.0.10
7
  Author: iubenda
8
  Author URI: https://www.iubenda.com
9
  License: MIT License
@@ -32,9 +32,11 @@ define( 'IUB_DEBUG', false );
32
  * iubenda final class.
33
  *
34
  * @property-read iubenda_Settings $settings
 
 
35
  *
36
  * @class iubenda
37
- * @version 3.0.10
38
  */
39
  class iubenda {
40
 
@@ -92,7 +94,7 @@ class iubenda {
92
  )
93
  );
94
  public $base_url;
95
- public $version = '3.0.10';
96
  public $activation = array(
97
  'update_version' => 0,
98
  'update_notice' => true,
@@ -166,6 +168,7 @@ class iubenda {
166
  self::$instance->forms = new iubenda_Forms();
167
  self::$instance->settings = new iubenda_Settings();
168
  self::$instance->widget = new IubendaLegalWidget();
 
169
  }
170
 
171
  return self::$instance;
@@ -236,7 +239,6 @@ class iubenda {
236
  return $actions;
237
  }
238
 
239
-
240
  /**
241
  * Setup plugin constants.
242
  *
@@ -263,6 +265,7 @@ class iubenda {
263
  include_once( IUBENDA_PLUGIN_PATH . 'includes/PrivacyPolicyGenerator.php' );
264
  include_once( IUBENDA_PLUGIN_PATH . 'includes/ServiceRating.php' );
265
  include_once( IUBENDA_PLUGIN_PATH . 'includes/widget/IubendaLegalWidget.php' );
 
266
  include_once( IUBENDA_PLUGIN_PATH . 'includes/ProductHelper.php' );
267
  }
268
 
@@ -366,6 +369,9 @@ class iubenda {
366
  delete_option( 'iubenda_tc_page_configuration' );
367
  delete_option( 'iubenda_terms_conditions_solution' );
368
  delete_option( iubenda_Settings::IUB_NOTIFICATIONS );
 
 
 
369
  }
370
 
371
  // remove radar options from database
@@ -1204,6 +1210,34 @@ class iubenda {
1204
  return version_compare( $db_version, $this->version, '<' );
1205
  }
1206
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1207
  }
1208
 
1209
  if (!function_exists('iub_array_get')) {
3
  Plugin Name: Cookie and Consent Solution for the GDPR & ePrivacy
4
  Plugin URI: https://www.iubenda.com
5
  Description: An All-in-One approach developed by iubenda, which includes functionalities of two powerful solutions that help to make your website GDPR and ePrivacy compliant.
6
+ Version: 3.1.0
7
  Author: iubenda
8
  Author URI: https://www.iubenda.com
9
  License: MIT License
32
  * iubenda final class.
33
  *
34
  * @property-read iubenda_Settings $settings
35
+ * @property IubendaLegalWidget $widget
36
+ * @property IubendaLegalBlock $block
37
  *
38
  * @class iubenda
39
+ * @version 3.1.0
40
  */
41
  class iubenda {
42
 
94
  )
95
  );
96
  public $base_url;
97
+ public $version = '3.1.0';
98
  public $activation = array(
99
  'update_version' => 0,
100
  'update_notice' => true,
168
  self::$instance->forms = new iubenda_Forms();
169
  self::$instance->settings = new iubenda_Settings();
170
  self::$instance->widget = new IubendaLegalWidget();
171
+ self::$instance->block = new IubendaLegalBlock();
172
  }
173
 
174
  return self::$instance;
239
  return $actions;
240
  }
241
 
 
242
  /**
243
  * Setup plugin constants.
244
  *
265
  include_once( IUBENDA_PLUGIN_PATH . 'includes/PrivacyPolicyGenerator.php' );
266
  include_once( IUBENDA_PLUGIN_PATH . 'includes/ServiceRating.php' );
267
  include_once( IUBENDA_PLUGIN_PATH . 'includes/widget/IubendaLegalWidget.php' );
268
+ include_once( IUBENDA_PLUGIN_PATH . 'includes/block/IubendaLegalBlock.php' );
269
  include_once( IUBENDA_PLUGIN_PATH . 'includes/ProductHelper.php' );
270
  }
271
 
369
  delete_option( 'iubenda_tc_page_configuration' );
370
  delete_option( 'iubenda_terms_conditions_solution' );
371
  delete_option( iubenda_Settings::IUB_NOTIFICATIONS );
372
+
373
+ // Detach iubenda legal block from footer
374
+ $this->block->detach_legal_block_from_footer();
375
  }
376
 
377
  // remove radar options from database
1210
  return version_compare( $db_version, $this->version, '<' );
1211
  }
1212
 
1213
+ /**
1214
+ * Decide which will be included into footer (Block or Widget)
1215
+ */
1216
+ public function assign_legal_block_or_widget()
1217
+ {
1218
+ // If current theme supports widget
1219
+ if ($this->widget->check_current_theme_supports_widget()) {
1220
+ do_action('iubenda_assign_widget_to_first_sidebar');
1221
+ }
1222
+
1223
+ // if current theme supports blocks
1224
+ if ($this->block->check_current_theme_supports_blocks()) {
1225
+ do_action('iubenda_attach_block_in_footer');
1226
+ }
1227
+ }
1228
+
1229
+ /**
1230
+ * Check if we support current theme to attach legal
1231
+ */
1232
+ public function check_if_we_support_current_theme_to_attach_legal()
1233
+ {
1234
+ if ($this->widget->check_current_theme_supports_widget() || $this->block->check_current_theme_supports_blocks()) {
1235
+ return true;
1236
+ }
1237
+
1238
+ return false;
1239
+ }
1240
+
1241
  }
1242
 
1243
  if (!function_exists('iub_array_get')) {
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: cookie banner, cookie law, eprivacy, gdpr, ukgdpr, ccpa, caloppa, lgpd, ds
5
  Requires at least: 5.0
6
  Requires PHP: 7.0.0
7
  Tested up to: 6.0
8
- Stable tag: 3.0.10
9
  License: MIT License
10
  License URI: http://opensource.org/licenses/MIT
11
 
@@ -242,6 +242,10 @@ The Brazilian General Data Protection Law, the ***Lei Geral de Proteção de Dad
242
 
243
  == Changelog ==
244
 
 
 
 
 
245
  = 3.0.10 =
246
  * Add a link to show the rating calculation page
247
  * Show Notification to encourage the user to verify his account
@@ -682,6 +686,6 @@ The Brazilian General Data Protection Law, the ***Lei Geral de Proteção de Dad
682
 
683
  == Upgrade Notice ==
684
 
685
- = 3.0.10 =
686
- * Add a link to show the rating calculation page
687
- * Show Notification to encourage the user to verify his account
5
  Requires at least: 5.0
6
  Requires PHP: 7.0.0
7
  Tested up to: 6.0
8
+ Stable tag: 3.1.0
9
  License: MIT License
10
  License URI: http://opensource.org/licenses/MIT
11
 
242
 
243
  == Changelog ==
244
 
245
+ = 3.1.0 =
246
+ * Move plugin settings to a separate page
247
+ * Add the ability to include PP and TC buttons for default WP
248
+
249
  = 3.0.10 =
250
  * Add a link to show the rating calculation page
251
  * Show Notification to encourage the user to verify his account
686
 
687
  == Upgrade Notice ==
688
 
689
+ = 3.1.0 =
690
+ * Move plugin settings to a separate page
691
+ * Add the ability to include PP and TC buttons for default WP
views/cs-configuration.php CHANGED
@@ -7,25 +7,8 @@
7
  <input hidden name="iubenda_section_key" value="cs">
8
  <input hidden name="action" value="ajax_save_options">
9
  <input hidden name="_redirect" value="<?php echo esc_url(add_query_arg(['view' => 'products-page'], iubenda()->base_url)) ?>">
10
- <div>
11
- <div class="p-4 p-lg-5 cookie-tab-settings">
12
- <div class="container-cookie-tabs tabs tabs--style1">
13
-
14
- <ul class="tabs__nav">
15
- <li class="tabs__nav__item active" data-target="general-settings" data-group="main-settings"><?php _e('General settings', 'iubenda') ?></li>
16
- <li class="tabs__nav__item" data-target="plugin-settings" data-group="main-settings"><?php _e('Plugin settings', 'iubenda') ?></li>
17
- </ul>
18
-
19
- <div data-target="general-settings" class="tabs__target active" data-group="main-settings">
20
- <?php require_once IUBENDA_PLUGIN_PATH . 'views/partials/csGeneralSettings.php'; ?>
21
- </div>
22
-
23
- <div data-target="plugin-settings" class="tabs__target plugin-settings-tab" data-group="main-settings">
24
- <?php require_once IUBENDA_PLUGIN_PATH . 'views/partials/csPluginSettings.php'; ?>
25
- </div>
26
-
27
- </div>
28
- </div>
29
  </div>
30
  <hr>
31
  <div class="p-4 d-flex justify-content-end">
7
  <input hidden name="iubenda_section_key" value="cs">
8
  <input hidden name="action" value="ajax_save_options">
9
  <input hidden name="_redirect" value="<?php echo esc_url(add_query_arg(['view' => 'products-page'], iubenda()->base_url)) ?>">
10
+ <div class="p-4 p-lg-5">
11
+ <?php require_once IUBENDA_PLUGIN_PATH . 'views/partials/csGeneralSettings.php'; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  </div>
13
  <hr>
14
  <div class="p-4 d-flex justify-content-end">
views/partials/buttonPosition.php CHANGED
@@ -11,15 +11,21 @@
11
  </label>
12
  </div>
13
  <?php
14
- global $wp_registered_sidebars;
 
 
 
 
 
 
 
 
15
 
16
- // If sidebar-1 not registered or not activated
17
- if (!boolval(iub_array_get($wp_registered_sidebars, 'sidebar-1'))) {
18
  ?>
19
  <section id="pp_button_position_automatically" class="pp_button_position <?php echo iub_array_get(iubenda()->options['pp'], 'button_position') == 'automatic' ?:'hidden' ; ?>">
20
  <div class="notice notice--warning mt-2 mb-4 p-3 d-flex align-items-center text-warning text-xs">
21
  <img class="mr-2" src="<?php echo IUBENDA_PLUGIN_URL ?>/assets/images/warning-icon.svg">
22
- <p><?php echo sprintf( __( 'We were not able to add a "Legal" widget to the footer as your theme is not compatible, you can position the "Legal" widget manually from <a href="%s" target="_blank">here</a>.', 'iubenda' ), esc_url( admin_url( 'widgets.php' ) ) ) ?></p>
23
  </div>
24
  </section>
25
  <?php
11
  </label>
12
  </div>
13
  <?php
14
+ // Check if we support current theme to attach legal
15
+ if (!iubenda()->check_if_we_support_current_theme_to_attach_legal()) {
16
+ $url = 'javascript:void(0)';
17
+
18
+ if(iubenda()->widget->check_current_theme_supports_widget()){
19
+ $url = admin_url( 'widgets.php' );
20
+ }elseif(iubenda()->block->check_current_theme_supports_blocks()){
21
+ $url = admin_url( 'site-editor.php' );
22
+ }
23
 
 
 
24
  ?>
25
  <section id="pp_button_position_automatically" class="pp_button_position <?php echo iub_array_get(iubenda()->options['pp'], 'button_position') == 'automatic' ?:'hidden' ; ?>">
26
  <div class="notice notice--warning mt-2 mb-4 p-3 d-flex align-items-center text-warning text-xs">
27
  <img class="mr-2" src="<?php echo IUBENDA_PLUGIN_URL ?>/assets/images/warning-icon.svg">
28
+ <p><?php echo sprintf( __( 'We were not able to add a "Legal" widget/block to the footer as your theme is not compatible, you can position the "Legal" widget/block manually from <a href="%s" target="_blank">here</a>.', 'iubenda' ), esc_url( $url ) ) ?></p>
29
  </div>
30
  </section>
31
  <?php
views/partials/csGeneralSettings.php CHANGED
@@ -1,4 +1,3 @@
1
- <div class="pt-4">
2
  <div class="tabs">
3
  <h3 class="text-bold text-gray text-md mb-0"><?php _e('Configuration', 'iubenda') ?></h3>
4
  <div class="scrollable gap-fixer">
@@ -143,4 +142,113 @@
143
  </table>
144
  </section>
145
  </section>
146
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <div class="tabs">
2
  <h3 class="text-bold text-gray text-md mb-0"><?php _e('Configuration', 'iubenda') ?></h3>
3
  <div class="scrollable gap-fixer">
142
  </table>
143
  </section>
144
  </section>
145
+
146
+ <div class="d-flex align-items-center pt-3">
147
+ <label class="checkbox-regular">
148
+ <input type="checkbox" name="iubenda_cookie_law_solution[parse]" value="1" class="mr-2 section-checkbox-control" data-section-name="#iub_parser_engine_container" <?php checked( true, (bool) iubenda()->options['cs']['parse'] ) ?>>
149
+ <span><?php _e('Automatically block scripts detected by the plugin', 'iubenda') ?> <a target="_blank" href="<?php echo iubenda()->settings->links['automatic_block_scripts']; ?>" class="ml-1 tooltip-icon">?</a></span>
150
+ </label>
151
+ </div>
152
+ <section id="iub_parser_engine_container" class="subOptions <?php echo (bool) iubenda()->options['cs']['parse']?: 'hidden' ?>">
153
+ <h4><?php _e('Select Parsing Engine', 'iubenda') ?></h4>
154
+ <div class="mb-3 d-flex flex-wrap align-items-center">
155
+ <label class="radio-regular mr-4">
156
+ <input type="radio" name="iubenda_cookie_law_solution[parser_engine]" value="new" class="mr-2 section-radio-control" <?php checked( 'new', iubenda()->options['cs']['parser_engine'] ) ?>>
157
+ <span><?php _e('Primary', 'iubenda') ?></span>
158
+ </label>
159
+ <label class="mr-4 radio-regular text-xs">
160
+ <input type="radio" name="iubenda_cookie_law_solution[parser_engine]" value="default" class="mr-2 section-radio-control" <?php checked( 'default', iubenda()->options['cs']['parser_engine'] ) ?>>
161
+ <span><?php _e('Secondary', 'iubenda') ?></span>
162
+ </label>
163
+ </div>
164
+ <br>
165
+ <div class="mb-2 d-flex flex-wrap align-items-center">
166
+ <label class="checkbox-regular">
167
+ <input type="checkbox" name="iubenda_cookie_law_solution[skip_parsing]" value="1" class="mr-2 section-checkbox-control" data-section-name="#section-block-script" <?php checked( true, (bool) iubenda()->options['cs']['skip_parsing'] ) ?>>
168
+ <span><?php _e('Leave scripts untouched on the page if the user has already given consent', 'iubenda') ?></span>
169
+ </label>
170
+ <p class="px-3 mx-4"><?php _e("Enable this option to improve performance <strong>only</strong> if your site does <strong>not</strong> use a cache system or a cache plugin and if you're <strong>not</strong> collecting per-category consent. If you're in doubt, keep this setting disabled", 'iubenda') ?></p>
171
+ </div>
172
+
173
+ <h4><?php _e('Blocked domains', 'iubenda') ?></h4>
174
+ <fieldset class="custom-scripts mb-3 p-0 tabs tabs--style2">
175
+ <ul class="tabs__nav text-xs">
176
+ <li data-target="tab-custom-scripts" data-group="custom-scripts" class="tabs__nav__item active"><?php _e('Custom scripts', 'iubenda') ?></li>
177
+ <li data-target="tab-custom-iframes" data-group="custom-scripts" class="tabs__nav__item"><?php _e('Custom iframes', 'iubenda') ?></li>
178
+ </ul>
179
+ <div data-target="tab-custom-scripts" data-group="custom-scripts" class="tabs__target p-3 active">
180
+ <section id="custom-script-field" class="custom-script-field hidden">
181
+ <input type="text" class="regular-text" name="iubenda_cookie_law_solution[custom_scripts][script][]" placeholder="Enter custom script" disabled>
182
+ <select name="iubenda_cookie_law_solution[custom_scripts][type][]" disabled>
183
+ <option value="0" selected="selected"><?php _e('Not set', 'iubenda') ?></option>
184
+ <option value="1"><?php _e('Strictly necessary', 'iubenda') ?></option>
185
+ <option value="2"><?php _e('Basic interactions &amp; functionalities', 'iubenda') ?></option>
186
+ <option value="3"><?php _e('Experience enhancement', 'iubenda') ?></option>
187
+ <option value="4"><?php _e('Analytics', 'iubenda') ?></option>
188
+ <option value="5"><?php _e('Targeting &amp; Advertising', 'iubenda') ?></option>
189
+ </select>
190
+ <a target="_blank" href="javascript:void(0)" class="remove-custom-script-field button-secondary remove-custom-section" data-remove-section=".custom-script-field" title="Remove">-</a>
191
+ </section>
192
+ <div id="custom-script-fields">
193
+ <?php
194
+ foreach (iubenda()->options['cs']['custom_scripts'] as $script => $type){
195
+ ?>
196
+ <section class="custom-script-field">
197
+ <input type="text" class="regular-text" name="iubenda_cookie_law_solution[custom_scripts][script][]" placeholder="Enter custom script" value="<?php echo esc_attr( stripslashes($script) ); ?>">
198
+ <select name="iubenda_cookie_law_solution[custom_scripts][type][]">
199
+ <option value="0" <?php selected( $type, 0 ); ?>><?php _e('Not set', 'iubenda') ?></option>
200
+ <option value="1" <?php selected( $type, 1 ); ?>><?php _e('Strictly necessary', 'iubenda') ?></option>
201
+ <option value="2" <?php selected( $type, 2 ); ?>><?php _e('Basic interactions &amp; functionalities', 'iubenda') ?></option>
202
+ <option value="3" <?php selected( $type, 3 ); ?>><?php _e('Experience enhancement', 'iubenda') ?></option>
203
+ <option value="4" <?php selected( $type, 4 ); ?>><?php _e('Analytics', 'iubenda') ?></option>
204
+ <option value="5" <?php selected( $type, 5 ); ?>><?php _e('Targeting &amp; Advertising', 'iubenda') ?></option>
205
+ </select>
206
+ <a target="_blank" href="javascript:void(0)" class="remove-custom-script-field button-secondary remove-custom-section" data-remove-section=".custom-script-field" title="Remove">-</a>
207
+ </section>
208
+ <?php }?>
209
+ </div>
210
+
211
+ <p class=" text-gray-lighter m-0 mb-3"><?php _e("Provide a list of domains for any custom scripts you'd like to block, and assign their purposes. To make sure they are blocked correctly, please add domains in the same format as 'example.com', without any protocols e.g. 'http://' or 'https://'. You may also use wildcards (*) to include parent domains or subdomains.", 'iubenda') ?></p>
212
+ <button class="btn btn-gray-outline btn-xs add-custom-section" data-append-section="#custom-script-fields" data-clone-section="#custom-script-field"><?php _e('Add New Script', 'iubenda') ?></button>
213
+ </div>
214
+ <div data-target="tab-custom-iframes" data-group="custom-scripts" class="tabs__target p-3">
215
+ <section id="custom-iframe-field" class="custom-iframe-field hidden">
216
+ <input type="text" class="regular-text" name="iubenda_cookie_law_solution[custom_iframes][iframe][]" placeholder="Enter custom iframe" disabled>
217
+ <select name="iubenda_cookie_law_solution[custom_iframes][type][]" disabled>
218
+ <option value="0" selected="selected"><?php _e('Not set', 'iubenda') ?></option>
219
+ <option value="1"><?php _e('Strictly necessary', 'iubenda') ?></option>
220
+ <option value="2"><?php _e('Basic interactions &amp; functionalities', 'iubenda') ?></option>
221
+ <option value="3"><?php _e('Experience enhancement', 'iubenda') ?></option>
222
+ <option value="4"><?php _e('Analytics', 'iubenda') ?></option>
223
+ <option value="5"><?php _e('Targeting &amp; Advertising', 'iubenda') ?></option>
224
+ </select>
225
+ <a target="_blank" href="javascript:void(0)" class="remove-custom-iframe-field button-secondary remove-custom-section" data-remove-section=".custom-iframe-field" title="Remove">-</a>
226
+ </section>
227
+ <div id="custom-iframe-fields">
228
+ <?php
229
+ foreach (iub_array_get(iubenda()->options['cs'],'custom_iframes') as $iframe => $type){
230
+ ?>
231
+ <section id="custom-iframe-field" class="custom-iframe-field">
232
+ <input type="text" class="regular-text" name="iubenda_cookie_law_solution[custom_iframes][iframe][]" placeholder="Enter custom iframe" value='<?php echo esc_attr( stripslashes($iframe) ); ?>'>
233
+ <select name="iubenda_cookie_law_solution[custom_iframes][type][]">
234
+ <option value="0" <?php selected( $type, 0 ); ?>><?php _e('Not set', 'iubenda') ?></option>
235
+ <option value="1" <?php selected( $type, 1 ); ?>><?php _e('Strictly necessary', 'iubenda') ?></option>
236
+ <option value="2" <?php selected( $type, 2 ); ?>><?php _e('Basic interactions &amp; functionalities', 'iubenda') ?></option>
237
+ <option value="3" <?php selected( $type, 3 ); ?>><?php _e('Experience enhancement', 'iubenda') ?></option>
238
+ <option value="4" <?php selected( $type, 4 ); ?>><?php _e('Analytics', 'iubenda') ?></option>
239
+ <option value="5" <?php selected( $type, 5 ); ?>><?php _e('Targeting &amp; Advertising', 'iubenda') ?></option>
240
+ </select>
241
+ <a target="_blank" href="javascript:void(0)" class="remove-custom-iframe-field button-secondary remove-custom-section" data-remove-section=".custom-iframe-field" title="Remove">-</a>
242
+ </section>
243
+ <?php }?>
244
+
245
+ </div>
246
+ <p class="text-gray-lighter m-0 mb-3"><?php _e("Provide a list of domains for any custom iframes you'd like to block, and assign their purposes. To make sure they are blocked correctly, please add domains in the same format as 'example.com', without any protocols e.g. 'http://' or 'https://'. You may also use wildcards (*) to include parent domains or subdomains.", 'iubenda') ?></p>
247
+ <button class="btn btn-gray-outline btn-xs add-custom-section" data-append-section="#custom-iframe-fields" data-clone-section="#custom-iframe-field"><?php _e('Add New iframe', 'iubenda') ?></button>
248
+ </div>
249
+ </fieldset>
250
+ </section>
251
+
252
+ <div class="pt-3">
253
+
254
+ </div>
views/partials/modals/modal_almost_there.php CHANGED
@@ -46,14 +46,20 @@
46
  <section id="section-<?php echo $key; ?>" class="<?php echo $service['status']=='true' ? '':'hidden'; ?>">
47
  <h4 class="mb-3"><?php echo $service['label']; ?></h4>
48
  <?php
49
- global $wp_registered_sidebars;
 
 
 
 
 
 
 
 
50
 
51
- // If sidebar-1 not registered or not activated
52
- if (in_array($key, ['pp', 'tc']) && !boolval(iub_array_get($wp_registered_sidebars, 'sidebar-1'))) {
53
  ?>
54
  <div class="notice notice--warning mt-2 mb-4 p-3 d-flex align-items-center text-warning text-xs">
55
  <img class="mr-2" style="width: 3rem !important" src="<?php echo IUBENDA_PLUGIN_URL ?>/assets/images/warning-icon.svg">
56
- <p><?php echo sprintf( __( 'We were not able to add a "Legal" widget to the footer as your theme is not compatible, you can position the "Legal" widget manually from <a href="%s" target="_blank">here</a>.', 'iubenda' ), esc_url( admin_url( 'widgets.php' ) ) ) ?></p>
57
  </div>
58
  <?php
59
  }
46
  <section id="section-<?php echo $key; ?>" class="<?php echo $service['status']=='true' ? '':'hidden'; ?>">
47
  <h4 class="mb-3"><?php echo $service['label']; ?></h4>
48
  <?php
49
+ // Check if we support current theme to attach legal
50
+ if (!iubenda()->check_if_we_support_current_theme_to_attach_legal()) {
51
+ $url = 'javascript:void(0)';
52
+
53
+ if(iubenda()->widget->check_current_theme_supports_widget()){
54
+ $url = admin_url( 'widgets.php' );
55
+ }elseif(iubenda()->block->check_current_theme_supports_blocks()){
56
+ $url = admin_url( 'site-editor.php' );
57
+ }
58
 
 
 
59
  ?>
60
  <div class="notice notice--warning mt-2 mb-4 p-3 d-flex align-items-center text-warning text-xs">
61
  <img class="mr-2" style="width: 3rem !important" src="<?php echo IUBENDA_PLUGIN_URL ?>/assets/images/warning-icon.svg">
62
+ <p><?php echo sprintf( __( 'We were not able to add a "Legal" widget/block to the footer as your theme is not compatible, you can position the "Legal" widget/block manually from <a href="%s" target="_blank">here</a>.', 'iubenda' ), esc_url( $url ) ) ?></p>
63
  </div>
64
  <?php
65
  }
views/partials/siteInfo.php CHANGED
@@ -8,9 +8,12 @@
8
  $url = iubenda()->settings->links['privacy_policy_generator_edit'];
9
  }
10
  ?>
11
- <div>
12
- <h1 class="text-bold text-lg m-0"><?php echo parse_url(home_url())['host']; ?></h1>
13
- </div>
 
 
 
14
  </div>
15
  <div class="d-block d-lg-flex mt-lg-0 mt-4 align-items-center text-center text-lg-right">
16
  <div class="mr-lg-3 mb-lg-0 mb-4">
8
  $url = iubenda()->settings->links['privacy_policy_generator_edit'];
9
  }
10
  ?>
11
+ <div>
12
+ <h1 class="text-bold text-lg m-0"><?php echo parse_url(home_url())['host']; ?></h1>
13
+ <?php if (isset($show_products_page) && $show_products_page): ?>
14
+ <a class="link-underline" href="<?php echo add_query_arg(['view' => "plugin-settings"], iubenda()->base_url); ?>"><?php _e('Plugin settings', 'iubenda') ?></a>
15
+ <?php endif; ?>
16
+ </div>
17
  </div>
18
  <div class="d-block d-lg-flex mt-lg-0 mt-4 align-items-center text-center text-lg-right">
19
  <div class="mr-lg-3 mb-lg-0 mb-4">
views/plugin-settings.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php require_once IUBENDA_PLUGIN_PATH . '/views/partials/header.php'; ?>
2
+ <div class="main-box">
3
+ <?php require_once IUBENDA_PLUGIN_PATH . '/views/partials/siteInfo.php'; ?>
4
+ <?php require_once IUBENDA_PLUGIN_PATH . 'views/partials/breadcrumb.php'; ?>
5
+ <form class="ajax-form-to-options">
6
+ <input hidden name="iubenda_section_name" value="iubenda_cookie_law_solution">
7
+ <input hidden name="iubenda_section_key" value="plugin-settings">
8
+ <input hidden name="action" value="ajax_save_options">
9
+ <input hidden name="_redirect" value="<?php echo esc_url(add_query_arg(['view' => 'products-page'], iubenda()->base_url)) ?>">
10
+ <div class="p-3 m-3">
11
+ <label class="checkbox-regular">
12
+ <input type="checkbox" class="mr-2" name="iubenda_plugin_settings[ctype]" value="1" <?php checked( true, (bool) iubenda()->options['cs']['ctype'] ) ?>>
13
+ <span><?php _e('Restrict the plugin to run only for requests that have "Content-type: text / html" (recommended)', 'iubenda') ?></span>
14
+ </label>
15
+ <label class="checkbox-regular">
16
+ <input type="checkbox" class="mr-2" name="iubenda_plugin_settings[output_feed]" value="1" <?php checked( true, (bool) iubenda()->options['cs']['output_feed'] ) ?>>
17
+ <span><?php _e('Do not run the plugin inside the RSS feed (recommended)', 'iubenda') ?></span>
18
+ </label>
19
+ <label class="checkbox-regular">
20
+ <input type="checkbox" class="mr-2" name="iubenda_plugin_settings[output_post]" value="1" <?php checked( true, (bool) iubenda()->options['cs']['output_post'] ) ?>>
21
+ <span><?php _e('Do not run the plugin on POST requests (recommended)', 'iubenda') ?></span>
22
+ </label>
23
+ <label class="checkbox-regular">
24
+ <input type="checkbox" class="mr-2" name="iubenda_plugin_settings[deactivation]" value="1" <?php checked( true, (bool) iubenda()->options['cs']['deactivation'] ) ?>>
25
+ <span><?php _e('Delete all plugin data upon deactivation', 'iubenda') ?></span>
26
+ </label>
27
+ <div class="mb-5">
28
+ <h4><?php _e('Menu position', 'iubenda') ?></h4>
29
+ <div class="mb-2 d-flex align-items-center flex-wrap">
30
+ <label class="radio-regular mr-3">
31
+ <input type="radio" name="iubenda_plugin_settings[menu_position]" value="topmenu" class="mr-2" <?php checked( 'topmenu', iubenda()->options['cs']['menu_position'] ) ?>>
32
+ <span><?php _e('Top menu', 'iubenda') ?></span>
33
+ </label>
34
+ <label class="mr-4 radio-regular text-xs">
35
+ <input type="radio" name="iubenda_plugin_settings[menu_position]" value="submenu" class="mr-2" <?php checked( 'submenu', iubenda()->options['cs']['menu_position'] ) ?>>
36
+ <span><?php _e('Submenu', 'iubenda') ?></span>
37
+ </label>
38
+ </div>
39
+ <p class="description"><?php _e('Select whether to display iubenda in a top admin menu or the Settings submenu.', 'iubenda') ?></p>
40
+ </div>
41
+ </div>
42
+ <hr>
43
+ <div class="p-4 d-flex justify-content-end">
44
+ <input class="btn btn-gray-lighter btn-sm mr-2" type="button" value="<?php _e('Cancel', 'iubenda') ?>" onclick="window.location.href = '<?php echo esc_url(add_query_arg(array('view' => 'products-page'), iubenda()->base_url)) ?>'"/>
45
+ <button type="submit" class="btn btn-green-primary btn-sm" value="Save" name="save">
46
+ <span class="button__text"><?php _e('Save settings', 'iubenda') ?></span>
47
+ </button>
48
+ </div>
49
+ </form>
50
+ </div>
51
+ <?php require_once IUBENDA_PLUGIN_PATH . 'views/partials/footer.php'; ?>
views/tc-configuration.php CHANGED
@@ -66,15 +66,21 @@
66
  </label>
67
  </div>
68
  <?php
69
- global $wp_registered_sidebars;
 
 
 
 
 
 
 
 
70
 
71
- // If sidebar-1 not registered or not activated
72
- if (!boolval(iub_array_get($wp_registered_sidebars, 'sidebar-1'))){
73
  ?>
74
  <section id="tc_button_position_automatic" class="tc_button_position <?php echo iub_array_get(iubenda()->options['tc'], 'button_position') == 'automatic' ?:'hidden' ; ?>">
75
  <div class="notice notice--warning mt-2 mb-4 p-3 d-flex align-items-center text-warning text-xs">
76
  <img class="mr-2" src="<?php echo IUBENDA_PLUGIN_URL ?>/assets/images/warning-icon.svg">
77
- <p><?php echo sprintf( __( 'We were not able to add a "Legal" widget to the footer as your theme is not compatible, you can position the "Legal" widget manually from <a href="%s" target="_blank">here</a>.', 'iubenda' ), esc_url( admin_url( 'widgets.php' ) ) ) ?></p>
78
  </div>
79
  </section>
80
  <?php
66
  </label>
67
  </div>
68
  <?php
69
+ // Check if we support current theme to attach legal
70
+ if (!iubenda()->check_if_we_support_current_theme_to_attach_legal()) {
71
+ $url = 'javascript:void(0)';
72
+
73
+ if(iubenda()->widget->check_current_theme_supports_widget()){
74
+ $url = admin_url( 'widgets.php' );
75
+ }elseif(iubenda()->block->check_current_theme_supports_blocks()){
76
+ $url = admin_url( 'site-editor.php' );
77
+ }
78
 
 
 
79
  ?>
80
  <section id="tc_button_position_automatic" class="tc_button_position <?php echo iub_array_get(iubenda()->options['tc'], 'button_position') == 'automatic' ?:'hidden' ; ?>">
81
  <div class="notice notice--warning mt-2 mb-4 p-3 d-flex align-items-center text-warning text-xs">
82
  <img class="mr-2" src="<?php echo IUBENDA_PLUGIN_URL ?>/assets/images/warning-icon.svg">
83
+ <p><?php echo sprintf( __( 'We were not able to add a "Legal" widget/block to the footer as your theme is not compatible, you can position the "Legal" widget/block manually from <a href="%s" target="_blank">here</a>.', 'iubenda' ), esc_url( $url ) ) ?></p>
84
  </div>
85
  </section>
86
  <?php