Version Description
- wp-admin blank page bug fix
Download this release
Release Info
Developer | Facens |
Plugin | iubenda Cookie Solution for GDPR |
Version | 1.9.4 |
Comparing to | |
See all releases |
Code changes from version 1.9.3 to 1.9.4
- iubenda_cookie_solution.php +91 -86
- readme.txt +3 -0
iubenda_cookie_solution.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
-
<?php
|
2 |
/*
|
3 |
Plugin Name: Iubenda Cookie Solution
|
4 |
Plugin URI: https://www.iubenda.com
|
5 |
Description: Iubenda Cookie Solution permette di gestire tutti gli aspetti della cookie law su WP.
|
6 |
-
Author:
|
7 |
-
Version: 1.9.
|
8 |
Author URI: https://www.iubenda.com
|
9 |
*/
|
10 |
-
|
11 |
-
if(!function_exists('file_get_html')){
|
12 |
include_once 'simple_html_dom.php';
|
13 |
}
|
14 |
-
|
15 |
DEFINE('VOICE_MENU', 'Iubenda Cookie Solution');
|
16 |
DEFINE('URL_MENU', str_replace(' ', '_', VOICE_MENU));
|
17 |
DEFINE('IUB_REGEX_PATTERN', '/<!--IUB_COOKIE_POLICY_START-->(.*)<!--IUB_COOKIE_POLICY_END-->/sU');
|
18 |
-
|
19 |
|
20 |
/***************************************
|
21 |
-
*
|
22 |
* Add Iubenda JS script to the header
|
23 |
*
|
24 |
****************************************/
|
25 |
-
|
26 |
function strpos_array($haystack, $needle){
|
27 |
if(is_array($needle)){
|
28 |
foreach($needle as $need){
|
@@ -43,22 +43,22 @@
|
|
43 |
foreach($_COOKIE as $key => $value){
|
44 |
if(strpos_array($key, array('_iub_cs-s', '_iub_cs'))){
|
45 |
return true;
|
46 |
-
}
|
47 |
}
|
48 |
}
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
function iub_header(){
|
53 |
ob_start();
|
54 |
$iub_code = get_option('iub_code');
|
55 |
echo html_entity_decode(stripslashes($iub_code));
|
56 |
}
|
57 |
-
|
58 |
add_action('wp_head', 'iub_header', 99);
|
59 |
|
60 |
/***********************************
|
61 |
-
*
|
62 |
* Encode all the javascript/html content fetched from this comments:
|
63 |
*
|
64 |
* <!--IUB_COOKIE_POLICY_START-->
|
@@ -68,59 +68,59 @@
|
|
68 |
* AND
|
69 |
*
|
70 |
* [iub-cookie-solution]
|
71 |
-
*
|
72 |
* code
|
73 |
-
*
|
74 |
* [/iub-cookie-solution]
|
75 |
*
|
76 |
************************************/
|
77 |
-
|
78 |
function create_tags($html){
|
79 |
-
|
80 |
$elements = $html->find("*");
|
81 |
$js = '';
|
82 |
-
|
83 |
-
foreach($elements as $e){
|
84 |
-
|
85 |
switch($e->tag){
|
86 |
case 'script':
|
87 |
$s = $e->innertext;
|
88 |
$js.= '<script type="text/plain" class="_iub_cs_activate">'.$s.'</script>';
|
89 |
break;
|
90 |
-
|
91 |
default:
|
92 |
$js.= '<noscript class="_no_script_iub">';
|
93 |
$js.= $e->outertext;
|
94 |
$js.= '</noscript>';
|
95 |
-
break;
|
96 |
}
|
97 |
|
98 |
}
|
99 |
-
|
100 |
return $js;
|
101 |
}
|
102 |
|
103 |
|
104 |
function __shutdown(){
|
105 |
$final = '';
|
106 |
-
|
107 |
// We'll need to get the number of ob levels we're in, so that we can iterate over each, collecting
|
108 |
// that buffer's output into the final output.
|
109 |
$levels = count(ob_get_level());
|
110 |
-
|
111 |
for ($i = 0; $i < $levels; $i++){
|
112 |
$final .= ob_get_clean();
|
113 |
}
|
114 |
-
|
115 |
// Apply any filters to the final output
|
116 |
echo apply_filters('final_output', $final);
|
117 |
}
|
118 |
-
|
119 |
add_action('shutdown', '__shutdown', 0);
|
120 |
|
121 |
|
122 |
function __final_output($output){
|
123 |
-
|
124 |
$auto_script_tags = array(
|
125 |
'platform.twitter.com/widgets.js',
|
126 |
'apis.google.com/js/plusone.js',
|
@@ -128,29 +128,29 @@
|
|
128 |
'connect.facebook.net',
|
129 |
'www.youtube.com/iframe_api'
|
130 |
);
|
131 |
-
|
132 |
$auto_iframe_tags = array(
|
133 |
'youtube.com',
|
134 |
'platform.twitter.com',
|
135 |
'www.facebook.com/plugins/like.php',
|
136 |
'apis.google.com'
|
137 |
);
|
138 |
-
|
139 |
-
|
140 |
if(consentGiven()){
|
141 |
return $output;
|
142 |
}
|
143 |
-
|
144 |
/* Replace all the comments with js/html encoded code */
|
145 |
preg_match_all(IUB_REGEX_PATTERN, $output, $scripts);
|
146 |
if(is_array($scripts[1])){
|
147 |
$count = count($scripts[1]);
|
148 |
$js_scripts = array();
|
149 |
-
for($j=0; $j<$count; $j++){
|
150 |
$html = str_get_html($scripts[1][$j], $lowercase=true, $forceTagsClosed=true, $stripRN=false);
|
151 |
$js_scripts[] = create_tags($html);
|
152 |
}
|
153 |
-
|
154 |
if(is_array($scripts[1]) && is_array($js_scripts)){
|
155 |
if(count($scripts[1]) >= 1 && count($js_scripts) >= 1){
|
156 |
$output = strtr($output, array_combine($scripts[1], $js_scripts));
|
@@ -159,86 +159,91 @@
|
|
159 |
}
|
160 |
|
161 |
$html = str_get_html($output, $lowercase=true, $forceTagsClosed=true, $stripRN=false);
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
$
|
169 |
-
|
170 |
-
|
171 |
-
$s->class = $class . ' _iub_cs_activate';
|
172 |
-
$s->type = 'text/plain';
|
173 |
-
}else{
|
174 |
-
$src = $s->src;
|
175 |
-
if (strpos_array($src, $auto_script_tags) !== false) {
|
176 |
$class = $s->class;
|
177 |
-
$s->class = $class . ' _iub_cs_activate
|
178 |
$s->type = 'text/plain';
|
179 |
-
}
|
180 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
}
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
}
|
198 |
}
|
199 |
-
|
200 |
-
|
201 |
-
return $html;
|
202 |
|
|
|
|
|
|
|
|
|
203 |
}
|
204 |
|
205 |
add_filter('final_output', '__final_output', $output);
|
206 |
|
207 |
-
|
208 |
function iub_func($atts, $content = "") {
|
209 |
/* Shortcode function */
|
210 |
$html = str_get_html($content, $lowercase=true, $forceTagsClosed=true, $stripRN=false);
|
211 |
return create_tags($html);
|
212 |
}
|
213 |
|
214 |
-
|
215 |
add_shortcode('iub-cookie-policy', 'iub_func');
|
216 |
|
217 |
|
218 |
/***********************************
|
219 |
-
*
|
220 |
-
* Add menù item on the admin
|
221 |
*
|
222 |
************************************/
|
223 |
-
|
224 |
-
|
225 |
function iub_admin_actions() {
|
226 |
add_options_page(VOICE_MENU, VOICE_MENU, 1, URL_MENU, 'iub_admin');
|
227 |
}
|
228 |
-
|
229 |
|
230 |
function iub_admin(){
|
231 |
-
|
232 |
/* Handling POST DATA and FETCHING from DB */
|
233 |
if($_POST['iub_update_form'] == 1) {
|
234 |
|
235 |
-
$iub_code = htmlentities($_POST['iub_code']);
|
236 |
update_option('iub_code', $iub_code);
|
237 |
-
echo '<div class="updated"><p><strong>Opzioni salvate</strong></p></div>';
|
238 |
} else {
|
239 |
$iub_code = get_option('iub_code');
|
240 |
}
|
241 |
-
|
242 |
echo '
|
243 |
<div class="wrap">
|
244 |
<h2> iubenda Cookie Policy Solution</h2>
|
@@ -248,7 +253,7 @@
|
|
248 |
Codice iubenda<br>
|
249 |
<textarea name="iub_code" cols="44" rows="13">'.stripslashes($iub_code).'</textarea>
|
250 |
</p>
|
251 |
-
|
252 |
<p class="submit">
|
253 |
<input type="hidden" name="iub_update_form" value="1">
|
254 |
<input type="submit" name="Submit" value="Update">
|
@@ -257,13 +262,13 @@
|
|
257 |
<p>
|
258 |
Per informazioni ed istruzioni su questo plugin, visita questa guida:<br>
|
259 |
<a href="https://www.iubenda.com/it/help/posts/810">https://www.iubenda.com/it/help/posts/810</a>
|
260 |
-
|
261 |
</p>
|
262 |
-
|
263 |
</div>';
|
264 |
}
|
265 |
|
266 |
|
267 |
add_action('admin_menu', 'iub_admin_actions');
|
268 |
|
269 |
-
?>
|
1 |
+
<?php
|
2 |
/*
|
3 |
Plugin Name: Iubenda Cookie Solution
|
4 |
Plugin URI: https://www.iubenda.com
|
5 |
Description: Iubenda Cookie Solution permette di gestire tutti gli aspetti della cookie law su WP.
|
6 |
+
Author: iubenda
|
7 |
+
Version: 1.9.4
|
8 |
Author URI: https://www.iubenda.com
|
9 |
*/
|
10 |
+
|
11 |
+
if(!function_exists('file_get_html')){
|
12 |
include_once 'simple_html_dom.php';
|
13 |
}
|
14 |
+
|
15 |
DEFINE('VOICE_MENU', 'Iubenda Cookie Solution');
|
16 |
DEFINE('URL_MENU', str_replace(' ', '_', VOICE_MENU));
|
17 |
DEFINE('IUB_REGEX_PATTERN', '/<!--IUB_COOKIE_POLICY_START-->(.*)<!--IUB_COOKIE_POLICY_END-->/sU');
|
18 |
+
|
19 |
|
20 |
/***************************************
|
21 |
+
*
|
22 |
* Add Iubenda JS script to the header
|
23 |
*
|
24 |
****************************************/
|
25 |
+
|
26 |
function strpos_array($haystack, $needle){
|
27 |
if(is_array($needle)){
|
28 |
foreach($needle as $need){
|
43 |
foreach($_COOKIE as $key => $value){
|
44 |
if(strpos_array($key, array('_iub_cs-s', '_iub_cs'))){
|
45 |
return true;
|
46 |
+
}
|
47 |
}
|
48 |
}
|
49 |
+
|
50 |
+
|
51 |
+
|
52 |
function iub_header(){
|
53 |
ob_start();
|
54 |
$iub_code = get_option('iub_code');
|
55 |
echo html_entity_decode(stripslashes($iub_code));
|
56 |
}
|
57 |
+
|
58 |
add_action('wp_head', 'iub_header', 99);
|
59 |
|
60 |
/***********************************
|
61 |
+
*
|
62 |
* Encode all the javascript/html content fetched from this comments:
|
63 |
*
|
64 |
* <!--IUB_COOKIE_POLICY_START-->
|
68 |
* AND
|
69 |
*
|
70 |
* [iub-cookie-solution]
|
71 |
+
*
|
72 |
* code
|
73 |
+
*
|
74 |
* [/iub-cookie-solution]
|
75 |
*
|
76 |
************************************/
|
77 |
+
|
78 |
function create_tags($html){
|
79 |
+
|
80 |
$elements = $html->find("*");
|
81 |
$js = '';
|
82 |
+
|
83 |
+
foreach($elements as $e){
|
84 |
+
|
85 |
switch($e->tag){
|
86 |
case 'script':
|
87 |
$s = $e->innertext;
|
88 |
$js.= '<script type="text/plain" class="_iub_cs_activate">'.$s.'</script>';
|
89 |
break;
|
90 |
+
|
91 |
default:
|
92 |
$js.= '<noscript class="_no_script_iub">';
|
93 |
$js.= $e->outertext;
|
94 |
$js.= '</noscript>';
|
95 |
+
break;
|
96 |
}
|
97 |
|
98 |
}
|
99 |
+
|
100 |
return $js;
|
101 |
}
|
102 |
|
103 |
|
104 |
function __shutdown(){
|
105 |
$final = '';
|
106 |
+
|
107 |
// We'll need to get the number of ob levels we're in, so that we can iterate over each, collecting
|
108 |
// that buffer's output into the final output.
|
109 |
$levels = count(ob_get_level());
|
110 |
+
|
111 |
for ($i = 0; $i < $levels; $i++){
|
112 |
$final .= ob_get_clean();
|
113 |
}
|
114 |
+
|
115 |
// Apply any filters to the final output
|
116 |
echo apply_filters('final_output', $final);
|
117 |
}
|
118 |
+
|
119 |
add_action('shutdown', '__shutdown', 0);
|
120 |
|
121 |
|
122 |
function __final_output($output){
|
123 |
+
|
124 |
$auto_script_tags = array(
|
125 |
'platform.twitter.com/widgets.js',
|
126 |
'apis.google.com/js/plusone.js',
|
128 |
'connect.facebook.net',
|
129 |
'www.youtube.com/iframe_api'
|
130 |
);
|
131 |
+
|
132 |
$auto_iframe_tags = array(
|
133 |
'youtube.com',
|
134 |
'platform.twitter.com',
|
135 |
'www.facebook.com/plugins/like.php',
|
136 |
'apis.google.com'
|
137 |
);
|
138 |
+
|
139 |
+
|
140 |
if(consentGiven()){
|
141 |
return $output;
|
142 |
}
|
143 |
+
|
144 |
/* Replace all the comments with js/html encoded code */
|
145 |
preg_match_all(IUB_REGEX_PATTERN, $output, $scripts);
|
146 |
if(is_array($scripts[1])){
|
147 |
$count = count($scripts[1]);
|
148 |
$js_scripts = array();
|
149 |
+
for($j=0; $j<$count; $j++){
|
150 |
$html = str_get_html($scripts[1][$j], $lowercase=true, $forceTagsClosed=true, $stripRN=false);
|
151 |
$js_scripts[] = create_tags($html);
|
152 |
}
|
153 |
+
|
154 |
if(is_array($scripts[1]) && is_array($js_scripts)){
|
155 |
if(count($scripts[1]) >= 1 && count($js_scripts) >= 1){
|
156 |
$output = strtr($output, array_combine($scripts[1], $js_scripts));
|
159 |
}
|
160 |
|
161 |
$html = str_get_html($output, $lowercase=true, $forceTagsClosed=true, $stripRN=false);
|
162 |
+
|
163 |
+
if(is_object($html)){
|
164 |
+
/* Auto match script and replace */
|
165 |
+
$scripts = $html->find("script");
|
166 |
+
if(is_array($scripts)){
|
167 |
+
$count = count($scripts);
|
168 |
+
for($j=0; $j<$count; $j++){
|
169 |
+
$s = $scripts[$j];
|
170 |
+
if (strpos_array($s->innertext, $auto_script_tags) !== false) {
|
|
|
|
|
|
|
|
|
|
|
171 |
$class = $s->class;
|
172 |
+
$s->class = $class . ' _iub_cs_activate';
|
173 |
$s->type = 'text/plain';
|
174 |
+
}else{
|
175 |
+
$src = $s->src;
|
176 |
+
if (strpos_array($src, $auto_script_tags) !== false) {
|
177 |
+
$class = $s->class;
|
178 |
+
$s->class = $class . ' _iub_cs_activate-inline';
|
179 |
+
$s->type = 'text/plain';
|
180 |
+
}
|
181 |
+
}
|
182 |
+
}
|
183 |
}
|
184 |
+
|
185 |
+
/* Auto match iframe and replace */
|
186 |
+
$iframes = $html->find("iframe");
|
187 |
+
if(is_array($iframes)){
|
188 |
+
$count = count($iframes);
|
189 |
+
for($j=0; $j<$count; $j++){
|
190 |
+
$i = $iframes[$j];
|
191 |
+
$src = $i->src;
|
192 |
+
if (strpos_array($src, $auto_iframe_tags) !== false){
|
193 |
+
$new_src = "data:text/html;base64,PGh0bWw+PGJvZHk+U3VwcHJlc3NlZDwvYm9keT48L2h0bWw+";
|
194 |
+
$class = $i->class;
|
195 |
+
$i->suppressedsrc = $src;
|
196 |
+
$i->src = $new_src;
|
197 |
+
$i->class = $class . ' _iub_cs_activate';
|
198 |
+
}
|
199 |
}
|
200 |
}
|
201 |
+
|
202 |
+
return $html;
|
|
|
203 |
|
204 |
+
}else{
|
205 |
+
return $output;
|
206 |
+
}
|
207 |
+
|
208 |
}
|
209 |
|
210 |
add_filter('final_output', '__final_output', $output);
|
211 |
|
212 |
+
|
213 |
function iub_func($atts, $content = "") {
|
214 |
/* Shortcode function */
|
215 |
$html = str_get_html($content, $lowercase=true, $forceTagsClosed=true, $stripRN=false);
|
216 |
return create_tags($html);
|
217 |
}
|
218 |
|
219 |
+
|
220 |
add_shortcode('iub-cookie-policy', 'iub_func');
|
221 |
|
222 |
|
223 |
/***********************************
|
224 |
+
*
|
225 |
+
* Add menù item on the admin
|
226 |
*
|
227 |
************************************/
|
228 |
+
|
229 |
+
|
230 |
function iub_admin_actions() {
|
231 |
add_options_page(VOICE_MENU, VOICE_MENU, 1, URL_MENU, 'iub_admin');
|
232 |
}
|
233 |
+
|
234 |
|
235 |
function iub_admin(){
|
236 |
+
|
237 |
/* Handling POST DATA and FETCHING from DB */
|
238 |
if($_POST['iub_update_form'] == 1) {
|
239 |
|
240 |
+
$iub_code = htmlentities($_POST['iub_code']);
|
241 |
update_option('iub_code', $iub_code);
|
242 |
+
echo '<div class="updated"><p><strong>Opzioni salvate</strong></p></div>';
|
243 |
} else {
|
244 |
$iub_code = get_option('iub_code');
|
245 |
}
|
246 |
+
|
247 |
echo '
|
248 |
<div class="wrap">
|
249 |
<h2> iubenda Cookie Policy Solution</h2>
|
253 |
Codice iubenda<br>
|
254 |
<textarea name="iub_code" cols="44" rows="13">'.stripslashes($iub_code).'</textarea>
|
255 |
</p>
|
256 |
+
|
257 |
<p class="submit">
|
258 |
<input type="hidden" name="iub_update_form" value="1">
|
259 |
<input type="submit" name="Submit" value="Update">
|
262 |
<p>
|
263 |
Per informazioni ed istruzioni su questo plugin, visita questa guida:<br>
|
264 |
<a href="https://www.iubenda.com/it/help/posts/810">https://www.iubenda.com/it/help/posts/810</a>
|
265 |
+
|
266 |
</p>
|
267 |
+
|
268 |
</div>';
|
269 |
}
|
270 |
|
271 |
|
272 |
add_action('admin_menu', 'iub_admin_actions');
|
273 |
|
274 |
+
?>
|
readme.txt
CHANGED
@@ -35,6 +35,9 @@ This plugin is described in English, browse down to the end of the readme to fin
|
|
35 |
|
36 |
== Changelog ==
|
37 |
|
|
|
|
|
|
|
38 |
= 1.9.3 =
|
39 |
* G+ platform bug, typo: _iub_cs_activate_inline vs _iub_cs_activate-inline
|
40 |
|
35 |
|
36 |
== Changelog ==
|
37 |
|
38 |
+
= 1.9.4 =
|
39 |
+
* wp-admin blank page bug fix
|
40 |
+
|
41 |
= 1.9.3 =
|
42 |
* G+ platform bug, typo: _iub_cs_activate_inline vs _iub_cs_activate-inline
|
43 |
|