- WordPress开启Nginx fastcgi_cache缓存加速
WordPress开启Nginx fastcgi_cache缓存加速,这是一篇转载并整理的文章,只为备忘,文章内容大部分来源于张戈博客。 在希望使用Nginx缓存前需要查看一下你的Nginx是否编译了ngx_cache_purge 模块,如果没有则需要...
- 实现高性能wordpress ajax文章分页功能
wordpress实现高性能的ajax文章分页功能。首先我们需要对后端进行处理,使除了当前使用AJAX可以无刷新浏览外,还可以直接请求改变的URL后也可以正常浏览。方法是对使用pushState的AJAX的发送一个特殊的头,当后端...
- 简单实用的网站动静分离优化方案
简单实用的网站动静分离优化方案,这是一篇转载文章,自己收藏起来慢慢琢磨。 先啰嗦一下网站动静分离的概念和好处。 一、动静分离 我们的网站简单来说分为 2 种数据资源,一种是动态的数据,即 PHP 等程序语言实...
- wordpress页面随机位置插入Adsense广告
该代码用于在循环内的随机位置输出adsense广告(或任何其他输出块),限制为预设数量的可能位置。<?php $ad_positions = array(1,2,4); // array of preset possible ad positions do { $rnd_ad = $ad_posit...
- WordPress 在文章随机段落中插入广告
WordPress 在文章随机段落中插入广告的实现方式很简单,只要把下面代码插入你主题的functions.php中即可实现(记得将:你的广告代码替换为你的广告内容)add_filter( 'the_content', 'prefix_insert_post_ads' ...
- php获取远程图片并下载保存到本地
php获取远程图片并下载保存到本地的方法。收藏备忘 远程图片指的是远端服务器上的数据我们可以通过php的许多函数来读取下载了,这里整理了几个可以自动下载远程图片并下载保存到本地的方法。 方法1,可以自动识别...
- WordPress检查一篇文章是否存在的方法
WordPress 两种方法 检查一篇文章是否存在,两个方法都需要先获取文章的id: 方法一:通过 get_permalink() 检测文章是否存在 if(get_permalink($post_id) === false){ // 文章不存在后执行操作 } 方法二:通...
- WordPress添加注册和登录用户名黑名单
WordPress添加注册和登录用户名黑名单实现代码(将下面代码加入主题的functions.php): //注册登录检查 function dmeng_check_authentication($username){ //用 | 分割用户名,且 | 前...
超强弹窗代码(24小时同一IP只弹一次)
超强弹窗代码,可以设置弹出窗口在最前还是自动隐藏,以及多长时间内弹出一次,代码分为两个文件:
//文件名:popup.js //收集整理:http://www.bangcang.com //参数:ptype,弹窗类型,当值=-1时弹出的窗口自动隐藏到当前窗口后面,否则在最前。 //popup.js var ptype=-1; function setcookie(cName,cExpires) { var cookie_time; try { cookie_time = parseFloat(cExpires) * 1; } catch(e) { cookie_time = 60*60; } if(isNaN(cookie_time)) cookie_time = 60*60; var then = new Date(); then.setTime(then.getTime() + cookie_time*1000); document.cookie=cName+'=1;expires='+ then.toGMTString()+';path=/;'; } function upcookie(cname,ctime){ setcookie(cname,ctime); } var state=0; ;(function(){ var d=navigator.userAgent; var a={}; a.ver={ ie:/MSIE/.test(d), ie6:!/MSIE 7\.0/.test(d)&&/MSIE 6\.0/.test(d)&&!/MSIE 8\.0/.test(d), tt:/TencentTraveler/.test(d), i360:/360SE/.test(d), sogo:/; SE/.test(d), gg:window.google&&window.chrome, _v1:'<object id="p01" width="0" height="0" classid="CLSID:6BF5'+'2A52-394'+'A-1'+'1D3-B15'+'3-00'+'C04F'+'79FAA6"></object>', _v2:'<object id="p02" style="position:absolute;left:1px;top:1px;width:1px;height:1px;" classid="clsid:2D'+'360201-FF'+'F5-11'+'d1-8D0'+'3-00A'+'0C95'+'9BC0A"></object>' }; if(a.ver.ie||a.ver.tt){ document.write(a.ver._v1);document.write(a.ver._v2); } a.fs=null;a.fdc=null;a.timeid=0;a.first=1;a.url='';a.w=0;a.h=0; a.init=function(){ try{ if(typeof document.body.onclick=="function"){ a.fs=document.body.onclick;document.body.onclick=null } if(typeof document.onclick=="function"){ if(document.onclick.toString().indexOf('clickpp')<0){ a.fdc=document.onclick;document.onclick=function(){ a.clickpp(a.url,a.w,a.h) } } } }catch(q){} }; a.donepp=function(c,g){ if (g==1 && (!a.ver.i360 && a.ver.ie6)) return; if (state) return; try{ document.getElementById("p01").launchURL(c);state=1;upcookie(popup_cookie_name,cookie_time) }catch(q){} }; a.clickpp=function(c,e,f){ a.open(c,e,f);clearInterval(a.timeid);document.onclick=null; if(typeof a.fdc=="function") try{document.onclick=a.fdc}catch(q){} if(typeof a.fs=="function") try{document.body.onclick=a.fs}catch(q){} } a.open=function(c,e,f){ if (state) return; a.url=c;a.w=e;a.h=f; if (a.timeid==0) a.timeid=setInterval(a.init,100); var b='height='+f+',width='+e+',left=0,top=0,toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes'; var j='window.open("'+c+'", "_blank", "'+b+'")'; var m=null; try{m=eval(j)}catch(q){} if(m && !(a.first && a.ver.gg)){ if (ptype!=-1){m.focus();}else{m.blur();window.focus();} state=1;upcookie(popup_cookie_name,cookie_time); if(typeof a.fs=="function") try{document.body.onclick=a.fs}catch(q){} clearInterval(a.timeid); }else{ var i=this, j=false; if(a.ver.ie||a.ver.tt){ document.getElementById("p01");document.getElementById("p02"); setTimeout(function(){ var obj=document.getElementById("p02"); if (state || !obj) return; try{ var wPop=obj.DOM.Script.open(c,"_blank",b); if (wPop){ if (ptype!=-1){wPop.focus();}else{wPop.blur();window.focus();} state=1;upcookie(popup_cookie_name,cookie_time); }else if (a.ver.sogo){state=1;upcookie(popup_cookie_name,cookie_time);} }catch(q){}},200); } if (a.first){ a.first=0; try{if(typeof document.onclick=="function") a.fdc=document.onclick}catch(p){} document.onclick=function(){i.clickpp(c,e,f)}; if (a.ver.ie){ if (window.attachEvent) window.attachEvent("onload", function(){i.donepp(c,1);}); else if (window.addEventListener) window.addEventListener("load", function(){i.donepp(c,1);},true); else window.onload=function(){i.donepp(c,1);}; } } } }; window.popup=a; })(); popup.open(gotourl, window.screen.width, window.screen.height);
另一个文件:
//文件名:dt.js //整理:http://www.bangcang.com //用法:在要弹窗的页面包含这个文件即可,下面还需要设置要弹出的广告地址和上面popup.js的路径 var ad = new Array(0); //这里可以建立多个广告地址 ad[0] = 'http://www.bangcang.com/guoguobang/pop.php'; //ad[1] = 'http://www.bangcang.com/guoguobang/pop2.php'; var cookie_time = 12*60*60; //cookie过期时间,现在设置的是12小时过期,也就是说12小时内只弹出一次 var showad=false; var index=0; if(!chk_cookie('rest')){ for (index=0;index < ad.length;index++) { popup_cookie_name = "tb02_"+index; if (!chk_cookie(popup_cookie_name)) { showad=true; break; } } } if(showad){ var then = new Date(); then.setTime(then.getTime() + 30*60*1000); // document.cookie='rest=1;expires='+ then.toGMTString()+';path=/;'; var gotourl=ad[index]; var popup_cookie_name = "tb02_"+index; alert("ok"); document.write("<SCR"+"IPT LANGUAGE=JavaScript1.1 SRC='/guoguobang/js/pop.js'><"+"/SCRIPT>"); //设置pop.js文件路径 } function chk_cookie(Name) { var search = Name + "=" var returnvalue = ""; if (document.cookie.length > 0) { offset = document.cookie.indexOf(search) if (offset != -1) { offset += search.length; end = document.cookie.indexOf(";", offset); if (end == -1) end = document.cookie.length; returnvalue=unescape(document.cookie.substring(offset, end)); } } return returnvalue; }
资料来源:http://www.bangcang.com/archives/11097
收藏备忘