iubenda Cookie Solution for GDPR - Version 1.9.3

Version Description

  • G+ platform bug, typo: iub_cs_activate_inline vs _iubcs_activate-inline
Download this release

Release Info

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

Version 1.9.3

Files changed (3) hide show
  1. iubenda_cookie_solution.php +269 -0
  2. readme.txt +139 -0
  3. simple_html_dom.php +1738 -0
iubenda_cookie_solution.php ADDED
@@ -0,0 +1,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: Duccio Catalioto
7
+ Version: 1.9.3
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){
29
+ if(strpos($haystack, $need) !== false){
30
+ return true;
31
+ }
32
+ }
33
+ }else{
34
+ if(strpos($haystack, $need) !== false) {
35
+ return true;
36
+ }
37
+ }
38
+ return false;
39
+ }
40
+
41
+
42
+ function consentGiven(){
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-->
65
+ * <script>..</script>
66
+ * <!--IUB_COOKIE_POLICY_END-->
67
+ *
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',
127
+ 'apis.google.com/js/platform.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));
157
+ }
158
+ }
159
+ }
160
+
161
+ $html = str_get_html($output, $lowercase=true, $forceTagsClosed=true, $stripRN=false);
162
+
163
+ /* Auto match script and replace */
164
+ $scripts = $html->find("script");
165
+ if(is_array($scripts)){
166
+ $count = count($scripts);
167
+ for($j=0; $j<$count; $j++){
168
+ $s = $scripts[$j];
169
+ if (strpos_array($s->innertext, $auto_script_tags) !== false) {
170
+ $class = $s->class;
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-inline';
178
+ $s->type = 'text/plain';
179
+ }
180
+ }
181
+ }
182
+ }
183
+
184
+ /* Auto match iframe and replace */
185
+ $iframes = $html->find("iframe");
186
+ if(is_array($iframes)){
187
+ $count = count($iframes);
188
+ for($j=0; $j<$count; $j++){
189
+ $i = $iframes[$j];
190
+ $src = $i->src;
191
+ if (strpos_array($src, $auto_iframe_tags) !== false){
192
+ $new_src = "data:text/html;base64,PGh0bWw+PGJvZHk+U3VwcHJlc3NlZDwvYm9keT48L2h0bWw+";
193
+ $class = $i->class;
194
+ $i->suppressedsrc = $src;
195
+ $i->src = $new_src;
196
+ $i->class = $class . ' _iub_cs_activate';
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>
245
+ <form name="iub_form" method="post" action="'.str_replace( '%7E', '~', $_SERVER['REQUEST_URI']).'">
246
+ <h4>Iubenda settings</h4>
247
+ <p>
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">
255
+ </p>
256
+ </form>
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
+ ?>
readme.txt ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Plugin Name ===
2
+ Contributors: iubenda
3
+ Donate link:
4
+ Tags: cookies, cookie law, cookie policy, cookie banner, cookie block, privacy policy, cookie consent
5
+ Requires at least: 3.0.1
6
+ Tested up to: 4.4.2
7
+ Stable tag: 1.0
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ Iubenda cookie solution plugin for WordPress for the creation of cookie banners and consent based cookie blocks. The plugin works with the Iubenda Cookie Law Solution and allows WordPress users to block the most common widgets to comply with the Cookie Law, particularly designed for Italy.
12
+
13
+ == Description ==
14
+
15
+ This plugin is described in English, browse down to the end of the readme to find an Italian version.
16
+
17
+ # Functionality
18
+
19
+ - The plugin automatically inserts the Iubenda code in the head of every page of the site
20
+ - It automatically blocks scripts by YouTube, Facebook, G + and Twitter (other automatic blocks on the way!)
21
+ - It allows to manually block all the remaining resources, without the need of direct intervention on the code
22
+ - It handles the display of cookie banners and cookie policy, saving user preferences about the use of cookies
23
+
24
+ == Installation ==
25
+
26
+ - **Manual installation**: download the plugin, go to the WordPress admin panel of your site and click on Plugins > Add New. At the top, then click the "upload plugin" button and then choose the ZIP file from your computer you just downloaded. Finally, click on "Install Now" and activate the plugin;
27
+ - **Installation via WP.org**: search in your WordPress plugin admin panel for "Iubenda Cookie Law Solution for Wordpress", install it;
28
+ - Once the plugin is installed and activated, go to the Admin Panel (Settings > Iubenda Cookie Solution) where you will be asked to paste the code into tht field that gets generated from your Iubenda account dashboard when you activate the cookie law kit for your privacy policy. For more information on how to activate the cookie law kit, see this article: https://www.iubenda.com/it/help/posts/680
29
+ - At this point the plugin will begin to show the banner on which displays your cookie policy (link) to users who visit the site for the first time. No need for other configurations.
30
+ - Furthermore, the plugin automatically recognizes and blocks cookies that get installed via the YouTube video player and social widgets - such as the Facebook Like Box - on your site.
31
+ - The other scripts that install cookies for which the automatic block isn't yet available can and should be "wrapped" using these comments:
32
+
33
+ `<!--IUB_COOKIE_POLICY_START-->
34
+ <!--IUB_COOKIE_POLICY_END-->`
35
+
36
+ == Changelog ==
37
+
38
+ = 1.9.3 =
39
+ * G+ platform bug, typo: _iub_cs_activate_inline vs _iub_cs_activate-inline
40
+
41
+ = 1.9.2 =
42
+ * G+ platform bug
43
+
44
+ = 1.9.1 =
45
+ * Minor improvements
46
+
47
+ = 1.9 =
48
+ * Improved parsing without regex
49
+ * No parsing if the user has already given the consent
50
+
51
+ = 1.0 =
52
+ * First plugin version.
53
+
54
+ == Usage ==
55
+
56
+ How does this plugin work with a Facebook button for example?
57
+
58
+ `<!--IUB_COOKIE_POLICY_START-->
59
+ <script>
60
+ (function(d, s, id) {
61
+ var js, fjs = d.getElementsByTagName(s)[0];
62
+ if (d.getElementById(id)) return;
63
+ js = d.createElement(s); js.id = id;
64
+ js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&#038;version=v2.3&#038;appId=808061959224601";
65
+ fjs.parentNode.insertBefore(js, fjs);
66
+ }(document, 'script', 'facebook-jssdk'));
67
+ </script>
68
+ <!--IUB_COOKIE_POLICY_END-->`
69
+
70
+ If there are HTML / IMG / IFRAME elements, you need to proceed in this way:
71
+
72
+ `<!--IUB_COOKIE_POLICY_START-->
73
+ <iframe src="...
74
+ <img src="...
75
+ <!--IUB_COOKIE_POLICY_END-->`
76
+
77
+ For articles, however, there's a shortcode available:
78
+
79
+ `[iub-cookie-policy]
80
+ [/iub-cookie-policy]`
81
+
82
+ In case of continued browsing, the preferences of your users for the use of cookies will be set on "OK" to clear the banner and unlock the cookies. Moreover, banners and the blocking codes will not be delivered to subsequent visits by users who have already given their consent (and such preference will be updated at each subsequent visit for the future).
83
+
84
+ == Further notes ==
85
+
86
+ At the moment the automatic blocking of the YouTube video player and social widgets are done only if these scripts are located after the function wp_head(). The solution is the first version. Test it and contact us to report any errors.
87
+
88
+ == Italian explanations ==
89
+
90
+ - Il plugin inserisce in modo automatico il codice di iubenda nell’head di tutte le pagine del sito
91
+ - Blocca in automatico i codici di YouTube, Facebook, G+ e Twitter (altri blocchi automatici in arrivo!)
92
+ - Permette di bloccare manualmente tutte le risorse restanti, senza la necessità di interventi diretti sul codice
93
+ - Gestisce la visualizzazione del banner e della cookie policy, ed il salvataggio delle preferenze degli utenti circa l’installazione dei cookie
94
+
95
+ # Istruzioni
96
+
97
+ - **Installazione manuale**: Scarica il plugin, accedi al pannello di amministrazione WordPress del tuo sito e clicca su Plugin > Aggiungi nuovo. In alto, clicca quindi sul pulsante Carica plugin e poi scegli dal tuo computer il file ZIP appena scaricato. Clicca infine su Installa adesso e attiva il plugin.
98
+ - **Installazione automatica**: installa dal repository WordPres.org cercando "Iubenda Cookie Law Solution for Wordpress"
99
+ - Una volta installato ed attivato il plugin, accedi al pannello Admin (Impostazioni > Iubenda Cookie Solution) dove ti verrà chiesto di incollare in un campo il codice che iubenda genera quando attivi il kit cookie law sulla tua privacy policy. Per ulteriori informazioni su come attivare il kit cookie law, consulta questo articolo: https://www.iubenda.com/it/help/posts/680
100
+ - A questo punto il plugin inizierà a mostrare il banner in cui è richiamata la tua cookie policy agli utenti che visitano il sito per la prima volta senza la necessità di altre configurazioni.
101
+ - In più, il plugin riconoscerà e bloccherà in automatico i cookie installati da tutti i video player di YouTube e dai widget sociali – come il Facebook Like Box – presenti sul tuo sito.
102
+ - Gli altri script per i quali non è ancora disponibile il blocco automatico – e che installano cookie che richiedono il blocco prima del consenso – vanno “avvolti” utilizzando questi commenti:
103
+
104
+ `<!--IUB_COOKIE_POLICY_START-->
105
+ <!--IUB_COOKIE_POLICY_END-->`
106
+
107
+ Per esempio in un plugin Facebook dovrai fare come segue:
108
+
109
+ `<!--IUB_COOKIE_POLICY_START-->
110
+ <script>
111
+ (function(d, s, id) {
112
+ var js, fjs = d.getElementsByTagName(s)[0];
113
+ if (d.getElementById(id)) return;
114
+ js = d.createElement(s); js.id = id;
115
+ js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&#038;version=v2.3&#038;appId=808061959224601";
116
+ fjs.parentNode.insertBefore(js, fjs);
117
+ }(document, 'script', 'facebook-jssdk'));
118
+ </script>
119
+ <!--IUB_COOKIE_POLICY_END-—>`
120
+
121
+ Se invece ci sono parti di HTML / IMG / IFRAME, bisogna procedere in questo modo:
122
+
123
+ `<!--IUB_COOKIE_POLICY_START-->
124
+ <iframe src="...
125
+ <img src="...
126
+ <!--IUB_COOKIE_POLICY_END-->`
127
+
128
+
129
+ Per gli articoli, invece, è disponibile uno shortcode:
130
+
131
+ `[iub-cookie-policy]
132
+ [/iub-cookie-policy]`
133
+
134
+
135
+ In caso di proseguimento della navigazione, le preferenze dei tuoi utenti circa l’installazione dei cookie verranno settate sul si in modo da far scomparire il banner e da sbloccare i cookie. Inoltre, banner e blocco codici non verranno erogati alle successive visite da parte degli utenti che hanno già prestato il proprio consenso (e tale preferenza verrà aggiornata ad ogni successiva visita).
136
+
137
+ **Note ulteriori:**
138
+
139
+ Al momento il blocco automatico dei video player di YouTube e dei widget sociali avviene solo se questi script si trovano dopo la funzione wp_head(). La soluzione è alla prima versione. Testatela e contattateci per segnalare eventuali errori.
simple_html_dom.php ADDED
@@ -0,0 +1,1738 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Website: http://sourceforge.net/projects/simplehtmldom/
4
+ * Additional projects that may be used: http://sourceforge.net/projects/debugobject/
5
+ * Acknowledge: Jose Solorzano (https://sourceforge.net/projects/php-html/)
6
+ * Contributions by:
7
+ * Yousuke Kumakura (Attribute filters)
8
+ * Vadim Voituk (Negative indexes supports of "find" method)
9
+ * Antcs (Constructor with automatically load contents either text or file/url)
10
+ *
11
+ * all affected sections have comments starting with "PaperG"
12
+ *
13
+ * Paperg - Added case insensitive testing of the value of the selector.
14
+ * Paperg - Added tag_start for the starting index of tags - NOTE: This works but not accurately.
15
+ * This tag_start gets counted AFTER \r\n have been crushed out, and after the remove_noice calls so it will no