Changeset 3031383
- Timestamp:
- 02/05/2024 07:50:50 AM (2 years ago)
- Location:
- bright-link-previews/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
bright-link-previews/trunk/index.php
r3024918 r3031383 4 4 Plugin URI: http://www.barattalo.it/ 5 5 Description: Show previews of links (clear, neat, simple), analyze links and track user behaviour on the links of your site 6 Version: 1. 66 Version: 1.7 7 7 Author: Giulio Pons 8 8 */ … … 222 222 */ 223 223 function blpwp_addClassToLinks($content, $classname) { 224 $doc = new DOMDocument(); 225 libxml_use_internal_errors(true); 226 $doc->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8')); 227 228 // Get the body element 229 $body = $doc->getElementsByTagName('body')->item(0); 230 231 // Iterate through the anchor tags within the body 232 foreach ($body->getElementsByTagName('a') as $tag) { 233 $tag->setAttribute('class', ($tag->hasAttribute('class') ? $tag->getAttribute('class') . ' ' : '') . $classname); 234 } 235 236 // Extract and return only the content of the body 237 $bodyContent = ''; 238 foreach ($body->childNodes as $child) { 239 $bodyContent .= $doc->saveHTML($child); 240 } 241 242 return $bodyContent; 224 if($content) { 225 $doc = new DOMDocument(); 226 libxml_use_internal_errors(true); 227 $doc->loadHTML('<?xml encoding="utf-8" ?>' . htmlspecialchars_decode($content)); 228 229 // Get the body element 230 $body = $doc->getElementsByTagName('body')->item(0); 231 232 // Iterate through the anchor tags within the body 233 foreach ($body->getElementsByTagName('a') as $tag) { 234 $tag->setAttribute('class', ($tag->hasAttribute('class') ? $tag->getAttribute('class') . ' ' : '') . $classname); 235 } 236 237 // Extract and return only the content of the body 238 $bodyContent = ''; 239 foreach ($body->childNodes as $child) { 240 $bodyContent .= $doc->saveHTML($child); 241 } 242 243 return $bodyContent; 244 } else { 245 return null; 246 } 243 247 } 244 248 … … 253 257 * */ 254 258 function blpwp_filter_the_content_links( $content ) { 255 if(!is_admin()) { 256 $options = get_option( 'blpwp_plugin_options' ); 257 $val = isset($options['contentlinks']) ? $options['contentlinks'] : ""; 258 if ($val) 259 return blpwp_addClassToLinks($content, "blpwp"); 260 } 261 return $content; 259 if($content) { 260 if(!is_admin()) { 261 $options = get_option( 'blpwp_plugin_options' ); 262 $val = isset($options['contentlinks']) ? $options['contentlinks'] : ""; 263 if ($val) 264 return blpwp_addClassToLinks($content, "blpwp"); 265 } 266 return $content; 267 } else { 268 return null; 269 } 262 270 } 263 271 add_filter( 'the_content', 'blpwp_filter_the_content_links', 10 ); -
bright-link-previews/trunk/script.js
r2967920 r3031383 12 12 ".mblpwp .blpwp_spot b {background:" + blpwp_params["options"]["color"] +"}" + 13 13 ".mblpwp .blpwp_spot b i {color:" + blpwp_params["options"]["fgcolor"] +"}" + 14 ".mblpwp .blpwp_wrap {background:" + blpwp_params["options"]["color0"] +"}" + 15 ".mblpwp .blpwp_wrap {color:" + blpwp_params["options"]["fgcolor0"] +"}</style>"); 16 17 function checkPic() { 18 span = $("#blpwp .blpwp_pics"); 19 if (typeof(span.data("images"))!== "undefined" && span.data("images")!="") { 20 arPics = span.data("images").split("|"); 21 var img = new Image(); 22 img.onload = function(){ 23 if(img.width * img.height > 2500) { 24 span.replaceWith("<img src=\"" + arPics[0] + "\" onerror=\"jQuery(this).hide();\">"); 25 if (img.width > img.height) { 26 $("#blpwp").addClass("horizontal").removeClass("vertical"); 14 ".mblpwp .blpwp_wrap {background:" + blpwp_params["options"]["color0"] +"}" + 15 ".mblpwp .blpwp_wrap {color:" + blpwp_params["options"]["fgcolor0"] +"}</style>"); 16 17 function checkPic() { 18 span = $("#blpwp .blpwp_pics"); 19 if (typeof(span.data("images"))!== "undefined" && span.data("images")!="") { 20 arPics = span.data("images").split("|"); 21 var img = new Image(); 22 img.onload = function(){ 23 if(img.width * img.height > 2500) { 24 span.replaceWith("<img src=\"" + arPics[0] + "\" onerror=\"jQuery(this).hide();\">"); 25 if (img.width > img.height) { 26 $("#blpwp").addClass("horizontal").removeClass("vertical"); 27 } else { 28 $("#blpwp").addClass("vertical").removeClass("horizontal"); 29 } 30 } else { 31 let images = span.data("images").replace(arPics[0],""); 32 images = images.replace(/^\|/, ''); 33 span.data("images", images); 34 checkPic(); // recursive call 35 } 36 } 37 img.src = arPics[0]; 38 } else { 39 $("#blpwp>div").addClass("nopic"); 40 } 41 } 42 43 var mTimer = false; 44 var triggerClick = (a) => { 45 46 $.ajax({ 47 url: blpwp_params['url'], 48 type :'POST', 49 data: { 50 "url": convertToAbsoluteURL( a.attr("href") ), 51 "idpost": blpwp_params['idpost'], 52 "action" : 'blpwpclick', 53 "rel" : a.attr("rel") 54 }, 55 success: function(html){ 56 if( a.data("preventClick") == 0) { 57 // normal links 58 if(blpwp_params['options'].blank == 'on') { 59 window.open( a.attr("href") ); 60 } else { 61 document.location = a.attr("href"); 62 } 63 } else { 64 closePopup(); 65 66 } 67 }, 68 }); 69 70 71 } 72 73 function addOverlayer(){ 74 $("body").data("css-overflow", $("body").css("overflow")); 75 $('body').append("<div id='underblpwp' class='" + blpwp_params['options'].style + "'></div>"); 76 $('body,html').css("overflow","hidden"); 77 // $('#blpwp').removeClass("fading"); 78 // console.log("rimosso") 79 // console.log($('#blpwp').attr("class")); 80 mTimer = setInterval(function(){ 81 // console.log("mTimer (opacity=" + $('#blpwp').css("opacity") + " " + ($('#blpwp').hasClass("fading")? "ha fading":"non ha fading")+")"); 82 if($('#blpwp').css("opacity") <= 0.05 && $('#blpwp').hasClass("fading")) { 83 // console.log("remove"); 84 $('#underblpwp').remove();$('#blpwp').remove(); 85 clearInterval(mTimer); 86 } 87 // click on dark layer close pop up 88 $('#underblpwp').on("click",function(e){ 89 e.preventDefault(); 90 e.stopPropagation(); 91 if($('#blpwp').css("opacity") >=.95 && !$('#blpwp').hasClass("fading")) { 92 // console.log("add fading"); 93 $('#blpwp').addClass("fading"); 94 $('body,html').css("overflow",$("body").data("css-overflow")); 95 } 96 }); 97 },500); 98 }; 99 100 function closePopup(){ 101 $('#blpwp').addClass("fading"); 102 if(mobile()) $('body,html').css("overflow",$("body").data("css-overflow")); 103 } 104 105 function showThisPop(a) { 106 // console.log("showThisPop"); 107 // console.log($('#blpwp').attr("class")); 108 $('#blpwp').html(a.data("html")).attr("class","mblpwp loaded " + blpwp_params['options'].style + " " + (mobile() ? "mob" :"") ); 109 checkPic(); 110 if(mobile()){ 111 $('#underblpwp').addClass("loaded"); 112 $('#blpwp').on("click",function(e){ 113 e.preventDefault(); 114 e.stopPropagation(); 115 // console.log("#blpwp.click"); 116 if(!$('#blpwp').hasClass("fading")) { 117 // console.log("not fading... open"); 118 triggerClick(a) 119 } 120 }); 121 } 122 } 123 124 function convertToAbsoluteURL(relativeURL) { 125 // Check if a <base> tag already exists 126 const existingBase = document.querySelector('base'); 127 let base; 128 if (existingBase) { 129 base = existingBase; 130 } else { 131 base = document.createElement('base'); 132 document.head.appendChild(base); 133 } 134 base.href = window.location.href; 135 const absoluteURL = new URL(relativeURL, base.href); 136 return absoluteURL.href; 137 } 138 139 function setupPopUp(a, e) { 140 currentA = convertToAbsoluteURL( e.target.getAttribute("href") ); 141 142 let h = convertToAbsoluteURL( a.attr("href") ); 143 144 if(a.data("html")==""){ 145 // search same link already retrieved 146 let s = 'a[href^="' + h+'"]'; 147 $(s).each(function(){ 148 if($(this).data("html")!="" && typeof($(this).data("html"))!=="undefined") { 149 // console.log("already used"); 150 a.data("html", $(this).data("html")); a.data("status",2); return; 151 } 152 }); 153 } 154 155 // link has status 0 and no html 156 if(a.data("html")=="" && a.data("status")==0){ 157 // add div container for popup and fetch content 158 $('#blpwp').html(_f("loading-preview")).attr("class","mblpwp loading a " + blpwp_params['options'].style + " " + (mobile() ? "mob" :"")); 159 a.data("status",1); 160 $.ajax({ 161 url: blpwp_params['url'], 162 type :'POST', 163 data: { 164 "geturl" : h, 165 "idpost" : blpwp_params['idpost'], 166 "action" : 'blpwpgetinfo', 167 "rel" : a.attr("rel") 168 }, 169 success: function(html){ 170 a.data("html",html); 171 a.data("status",2); // status = 2 ==> OK 172 // console.log(currentA + " == " +h + "(1)") 173 174 if(currentA == h || !currentA) showThisPop(a); 175 }, 176 }); 177 178 } else { 179 // there is html or status != 0 180 181 182 if(a.data("status")==1) { // link is loading 183 $('#blpwp').html(_f("loading-preview")).attr("class","mblpwp loading c " + blpwp_params['options'].style + " " + (mobile() ? "mob" :"")); 27 184 } else { 28 $("#blpwp").addClass("vertical").removeClass("horizontal"); 185 186 // status is 2 ==> OK 187 if(a.data("status") == 2 ) { 188 // console.log(currentA + " == " +h + "(2)") 189 if(currentA == h || !currentA) showThisPop(a); 190 } else { 191 // other 192 $('#blpwp').remove(); 193 } 29 194 } 30 } else { 31 let images = span.data("images").replace(arPics[0],""); 32 images = images.replace(/^\|/, ''); 33 span.data("images", images); 34 checkPic(); // recursive call 35 } 36 } 37 img.src = arPics[0]; 38 } else { 39 $("#blpwp>div").addClass("nopic"); 40 } 41 } 42 43 var mTimer = false; 44 var triggerClick = (a) => { 45 46 $.ajax({ 47 url: blpwp_params['url'], 48 type :'POST', 49 data: { 50 "url": convertToAbsoluteURL( a.attr("href") ), 51 "idpost": blpwp_params['idpost'], 52 "action" : 'blpwpclick', 53 "rel" : a.attr("rel") 54 }, 55 success: function(html){ 56 if( a.data("preventClick") == 0) { 57 // normal links 58 if(blpwp_params['options'].blank == 'on') { 59 window.open( a.attr("href") ); 60 } else { 61 document.location = a.attr("href"); 62 } 63 } else { 195 } 196 197 } 198 199 function prepareLayers(){ 200 201 // black layer on mobile 202 if($('#underblpwp').length == 0 && mobile()) { 203 addOverlayer(); 204 } 205 206 if($('#blpwp').length == 0) { 207 // add div container for popup if not exists 208 $("body").append("<div id='blpwp' class='mblpwp loading b " + blpwp_params['options'].style + " " + (mobile() ? "mob" :"") +"' style='font-size:" + blpwp_params['options'].size + "px'>" + _f("loading-preview") +"</div>"); 209 } 210 } 211 212 function followMouse(e){ 213 currentA = convertToAbsoluteURL( e.target.getAttribute("href") ); 214 215 $('#blpwp').removeClass("fading"); 216 217 let posX = e.pageX - $('#blpwp').width()/2; 218 if($('#blpwp').width() +20 + posX > $(window).width()) { 219 posX = $(window).width() - $('#blpwp').width() - 20; 220 } else if(posX < 0) { 221 posX = 0; 222 } 223 224 let posY = e.pageY +50; 225 if($('#blpwp').height() +50 + posY > $(document).height()) { 226 posY = $(document).height() - $('#blpwp').height() -50; 227 } 228 229 $('#blpwp').css({ 230 left: posX, 231 top: posY 232 }); 233 } 234 235 let $selector = ""; 236 if (blpwp_params['options'].contentlinks == 'on') $selector +="a.blpwp"; 237 if (blpwp_params['options'].commentlinks == 'on') $selector += ($selector!="" ? ", " : "" ) + "a.blpwp_comment"; 238 if (blpwp_params['options'].selectorchk == 'on' && blpwp_params['options'].selector!="") 239 $selector += ($selector!="" ? ", " : "" ) + blpwp_params['options'].selector; 240 241 // alert($selector) 242 243 $( $selector ).each(function(index){ 244 var a = $(this); 245 let h = convertToAbsoluteURL( a.attr("href") ); 246 247 if( blpwp_params['options'].counter == 'yes' ) { 248 setTimeout(function(){ 249 $.ajax({ 250 url: blpwp_params['url'], 251 type :'POST', 252 data: { 253 "url" : h, 254 "idpost" : blpwp_params['idpost'], 255 "action" : 'blpwpgetclick' 256 }, 257 success: function(html){ 258 if(html>"0") { 259 // there was an error 260 a.after("<sup class='blpwp_counter'>" + html+"<span> click</span></sup>"); 261 } 262 }, 263 }); 264 265 }, index * 500); 266 } 267 268 269 270 if( blpwp_params['options'].blank == 'on' && h.indexOf("http") == 0 && h.indexOf(blpwp_params["internals"]) == -1) { 271 a.attr("target","_blank"); 272 } 273 274 let check = blpwp_params['options'].extint == '' || h.indexOf("mailto:") == 0; 275 276 if (!check && blpwp_params['options'].extint == 'internal' && (h.indexOf("/") == 0 || h.indexOf(blpwp_params["internals"]) == 0 )) { 277 check = true; 278 } 279 280 if (!check && blpwp_params['options'].extint == 'external' && h.indexOf("http") == 0 && h.indexOf(blpwp_params["internals"]) == -1 ) { 281 check = true; 282 } 283 284 let preventClick = 0; 285 if (check && blpwp_params['options'].imagelinks == '' && h.match(/(\.(jpe?g|gif|png|webp))$/, 'i') && $(this).find("img").length == 1 && $(this).children().length == 1) { 286 check = false; 287 } 288 289 if (check) { 290 291 // console.log("check") 292 293 if ($(this).attr("href").indexOf("wp-admin")==-1 && $(this).attr("href").trim()!="") { 294 a.data("html",""); 295 a.data("status",0); 296 a.data("preventClick",preventClick); 297 a.on("click",function(e){ 298 e.preventDefault(); 299 e.stopPropagation(); 300 e.stopImmediatePropagation(); 301 302 // console.log("click") 303 304 if(mobile()) { 305 if(blpwp_params['options'].disable_mobile == 'on') { 306 triggerClick(a); 307 308 } else { 309 // on mobile the click open the pop up 310 311 prepareLayers(); 312 313 setupPopUp(a, e); 314 315 316 } 317 318 } else { 319 // on desktop the click is a click 320 321 triggerClick(a); 322 } 323 }); 324 a.on("mouseenter",function(e){ 325 if(!mobile()) { 326 327 prepareLayers(); 328 329 setupPopUp(a, e); 330 331 // on desktop popup follows cursor 332 a.on("mousemove",function(e){ 333 if(!mobile()) followMouse(e); 334 }); 335 } 336 }); 337 338 // on desktop remove pop up on exit 339 a.on("mouseleave",function(e){ 340 currentA = null; 341 if(!mobile()) $('#blpwp').addClass("fading"); 342 }); 343 344 } 345 } 346 }); 347 348 // on desktop when scroll remove pop up 349 $(window).on("scroll",function(){ 64 350 closePopup(); 65 66 } 67 }, 68 }); 69 70 71 } 72 73 function addOverlayer(){ 74 $("body").data("css-overflow", $("body").css("overflow")); 75 $('body').append("<div id='underblpwp' class='" + blpwp_params['options'].style + "'></div>"); 76 $('body,html').css("overflow","hidden"); 77 // $('#blpwp').removeClass("fading"); 78 // console.log("rimosso") 79 console.log($('#blpwp').attr("class")); 80 mTimer = setInterval(function(){ 81 console.log("mTimer (opacity=" + $('#blpwp').css("opacity") + " " + ($('#blpwp').hasClass("fading")? "ha fading":"non ha fading")+")"); 82 if($('#blpwp').css("opacity") <= 0.05 && $('#blpwp').hasClass("fading")) { 83 console.log("remove"); 84 $('#underblpwp').remove();$('#blpwp').remove(); 85 clearInterval(mTimer); 86 } 87 // click on dark layer close pop up 88 $('#underblpwp').on("click",function(e){ 89 e.preventDefault(); 90 e.stopPropagation(); 91 if($('#blpwp').css("opacity") >=.95 && !$('#blpwp').hasClass("fading")) { 92 console.log("add fading"); 93 $('#blpwp').addClass("fading"); 94 $('body,html').css("overflow",$("body").data("css-overflow")); 95 } 351 }); 352 $(window).on("resize",function(){ 353 closePopup(); 354 }); 355 356 96 357 }); 97 },500);98 };99 100 function closePopup(){101 $('#blpwp').addClass("fading");102 if(mobile()) $('body,html').css("overflow",$("body").data("css-overflow"));103 }104 105 function showThisPop(a) {106 console.log("showThisPop");107 console.log($('#blpwp').attr("class"));108 $('#blpwp').html(a.data("html")).attr("class","mblpwp loaded " + blpwp_params['options'].style + " " + (mobile() ? "mob" :"") );109 checkPic();110 if(mobile()){111 $('#underblpwp').addClass("loaded");112 $('#blpwp').on("click",function(e){113 e.preventDefault();114 e.stopPropagation();115 console.log("#blpwp.click");116 if(!$('#blpwp').hasClass("fading")) {117 // console.log("not fading... open");118 triggerClick(a)119 }120 });121 }122 }123 124 function convertToAbsoluteURL(relativeURL) {125 // Check if a <base> tag already exists126 const existingBase = document.querySelector('base');127 let base;128 if (existingBase) {129 base = existingBase;130 } else {131 base = document.createElement('base');132 document.head.appendChild(base);133 }134 base.href = window.location.href;135 const absoluteURL = new URL(relativeURL, base.href);136 return absoluteURL.href;137 }138 139 function setupPopUp(a, e) {140 currentA = convertToAbsoluteURL( e.target.getAttribute("href") );141 142 let h = convertToAbsoluteURL( a.attr("href") );143 144 if(a.data("html")==""){145 // search same link already retrieved146 let s = 'a[href^="' + h+'"]';147 $(s).each(function(){148 if($(this).data("html")!="" && typeof($(this).data("html"))!=="undefined") {149 console.log("already used");150 a.data("html", $(this).data("html")); a.data("status",2); return;151 }152 });153 }154 155 // link has status 0 and no html156 if(a.data("html")=="" && a.data("status")==0){157 // add div container for popup and fetch content158 $('#blpwp').html(_f("loading-preview")).attr("class","mblpwp loading a " + blpwp_params['options'].style + " " + (mobile() ? "mob" :""));159 a.data("status",1);160 $.ajax({161 url: blpwp_params['url'],162 type :'POST',163 data: {164 "geturl" : h,165 "idpost" : blpwp_params['idpost'],166 "action" : 'blpwpgetinfo',167 "rel" : a.attr("rel")168 },169 success: function(html){170 a.data("html",html);171 a.data("status",2); // status = 2 ==> OK172 console.log(currentA + " == " +h + "(1)")173 174 if(currentA == h || !currentA) showThisPop(a);175 },176 });177 178 } else {179 // there is html or status != 0180 181 182 if(a.data("status")==1) { // link is loading183 $('#blpwp').html(_f("loading-preview")).attr("class","mblpwp loading c " + blpwp_params['options'].style + " " + (mobile() ? "mob" :""));184 } else {185 186 // status is 2 ==> OK187 if(a.data("status") == 2 ) {188 console.log(currentA + " == " +h + "(2)")189 if(currentA == h || !currentA) showThisPop(a);190 } else {191 // other192 $('#blpwp').remove();193 }194 }195 }196 197 }198 199 function prepareLayers(){200 201 // black layer on mobile202 if($('#underblpwp').length == 0 && mobile()) {203 addOverlayer();204 }205 206 if($('#blpwp').length == 0) {207 // add div container for popup if not exists208 $("body").append("<div id='blpwp' class='mblpwp loading b " + blpwp_params['options'].style + " " + (mobile() ? "mob" :"") +"' style='font-size:" + blpwp_params['options'].size + "px'>" + _f("loading-preview") +"</div>");209 }210 }211 212 function followMouse(e){213 currentA = convertToAbsoluteURL( e.target.getAttribute("href") );214 215 $('#blpwp').removeClass("fading");216 217 let posX = e.pageX - $('#blpwp').width()/2;218 if($('#blpwp').width() +20 + posX > $(window).width()) {219 posX = $(window).width() - $('#blpwp').width() - 20;220 } else if(posX < 0) {221 posX = 0;222 }223 224 let posY = e.pageY +50;225 if($('#blpwp').height() +50 + posY > $(document).height()) {226 posY = $(document).height() - $('#blpwp').height() -50;227 }228 229 $('#blpwp').css({230 left: posX,231 top: posY232 });233 }234 235 let $selector = "";236 if (blpwp_params['options'].contentlinks == 'on') $selector +="a.blpwp";237 if (blpwp_params['options'].commentlinks == 'on') $selector += ($selector!="" ? ", " : "" ) + "a.blpwp_comment";238 if (blpwp_params['options'].selectorchk == 'on' && blpwp_params['options'].selector!="")239 $selector += ($selector!="" ? ", " : "" ) + blpwp_params['options'].selector;240 241 // alert($selector)242 243 $( $selector ).each(function(index){244 var a = $(this);245 let h = convertToAbsoluteURL( a.attr("href") );246 247 if( blpwp_params['options'].counter == 'yes' ) {248 setTimeout(function(){249 $.ajax({250 url: blpwp_params['url'],251 type :'POST',252 data: {253 "url" : h,254 "idpost" : blpwp_params['idpost'],255 "action" : 'blpwpgetclick'256 },257 success: function(html){258 if(html>"0") {259 // there was an error260 a.after("<sup class='blpwp_counter'>" + html+"<span> click</span></sup>");261 }262 },263 });264 265 }, index * 500);266 }267 268 269 270 if( blpwp_params['options'].blank == 'on' && h.indexOf("http") == 0 && h.indexOf(blpwp_params["internals"]) == -1) {271 a.attr("target","_blank");272 }273 274 let check = blpwp_params['options'].extint == '' || h.indexOf("mailto:") == 0;275 276 if (!check && blpwp_params['options'].extint == 'internal' && (h.indexOf("/") == 0 || h.indexOf(blpwp_params["internals"]) == 0 )) {277 check = true;278 }279 280 if (!check && blpwp_params['options'].extint == 'external' && h.indexOf("http") == 0 && h.indexOf(blpwp_params["internals"]) == -1 ) {281 check = true;282 }283 284 let preventClick = 0;285 if (check && blpwp_params['options'].imagelinks == '' && h.match(/(\.(jpe?g|gif|png|webp))$/, 'i') && $(this).find("img").length == 1 && $(this).children().length == 1) {286 check = false;287 }288 289 if (check) {290 291 console.log("check")292 293 if ($(this).attr("href").indexOf("wp-admin")==-1 && $(this).attr("href").trim()!="") {294 a.data("html","");295 a.data("status",0);296 a.data("preventClick",preventClick);297 a.on("click",function(e){298 e.preventDefault();299 e.stopPropagation();300 e.stopImmediatePropagation();301 302 console.log("click")303 304 if(mobile()) {305 // on mobile the click open the pop up306 307 prepareLayers();308 309 setupPopUp(a, e);310 311 } else {312 // on desktop the click is a click313 314 triggerClick(a);315 }316 });317 a.on("mouseenter",function(e){318 if(!mobile()) {319 320 prepareLayers();321 322 setupPopUp(a, e);323 324 // on desktop popup follows cursor325 a.on("mousemove",function(e){326 if(!mobile()) followMouse(e);327 });328 }329 });330 331 // on desktop remove pop up on exit332 a.on("mouseleave",function(e){333 currentA = null;334 if(!mobile()) $('#blpwp').addClass("fading");335 });336 337 }338 }339 });340 341 // on desktop when scroll remove pop up342 $(window).on("scroll",function(){343 closePopup();344 });345 $(window).on("resize",function(){346 closePopup();347 });348 349 350 }); -
bright-link-previews/trunk/settings-page.php
r2978369 r3031383 379 379 add_settings_field( 'blpwp_plugin_setting_blank', esc_html__('Force target','blpwp'), 'blpwp_plugin_setting_blank', 'blpwp_plugin', 'save_these_options' ); 380 380 381 // DISABLE ON MOBILE 382 add_settings_field( 'blpwp_plugin_setting_disable_mobile', esc_html__('Disable on mobile','blpwp'), 'blpwp_plugin_setting_disable_mobile', 'blpwp_plugin', 'save_these_options' ); 381 383 382 384 } … … 401 403 $newinput['cache'] = trim( $input['cache'] ); 402 404 $newinput['blank'] = $input['blank'] == "on" ? "on" : ""; 405 $newinput['disable_mobile'] = $input['disable_mobile'] == "on" ? "on" : ""; 403 406 return $newinput; 404 407 } … … 549 552 550 553 551 552 554 // DISABLE THE POP UP UN MOBILE 555 function blpwp_plugin_setting_disable_mobile() { 556 $options = get_option( 'blpwp_plugin_options' ); 557 $val = isset($options['disable_mobile']) ? $options['disable_mobile'] : ""; 558 echo "<input type='checkbox' id='blpwp_plugin_setting_disable_mobile' name='blpwp_plugin_options[disable_mobile]' value='on' ".($val=="on" ? "checked" : "")." /> "; 559 echo esc_html__("Disable the pop up on mobile",'blpwp'); 560 } 561
Note: See TracChangeset
for help on using the changeset viewer.