WP YouTube Lyte - Version 1.0.0

Version Description

  • new: also works on (manual) excerpts; just add a httpv link to the "excerpt" field on the post/page admin (based on feedback from Ruben@tuttingegneri)
  • new: if youtube-url contains "start" or "showinfo" parameters, these are used when playing the actual video. This means that you can now jump to a specific time in the YouTube video or stop the title/ author from being displayed (based on feedback from a.o. Miguel and Josh D)
  • update: javascript now initiates either after full page load or after 1 second (whatever comes first), thus avoiding video not showing due to other requests taking too long
  • update: bonus feature stops lockerz.com tracking by addtoany (you'll still want to hide the "earn pointz" tab though)
  • bugfix: prevent the playing video to be in front of e.g. a dropdown-menu or lightbox (thanks to Matt Whittingham)
  • bugfix: solve overlap between player and text when option was set not to show links (reported by Josh D)
Download this release

Release Info

Developer futtta
Plugin Icon 128x128 WP YouTube Lyte
Version 1.0.0
Comparing to
See all releases

Code changes from version 0.9.4 to 1.0.0

external/donottrack-min.js CHANGED
@@ -1 +1 @@
1
- function sanitizer(a){a=a.toLowerCase();if(mode==="blacklist"){for(x in list["black"]){if(a.indexOf(list["black"][x].toLowerCase())!==-1){a=true;break}}}else{for(x in list["white"]){if(a.indexOf(list["white"][x].toLowerCase())!==-1){tmpS=false;break}else{tmpS=true}}if(tmpS===true)a=tmpS}return a}function aop_around(a,b){aop.around({target:a,method:b},function(a){if(typeof a.arguments[0].src==="string"&&(a.arguments[0].tagName.toLowerCase()==="script"||a.arguments[0].tagName.toLowerCase()==="img")){if(sanitizer(a.arguments[0].src)===true){a.arguments[0].src="javascript:void(0)"}}return a.proceed()})}(function(){var _after=1;var _afterThrow=2;var _afterFinally=3;var _before=4;var _around=5;var _intro=6;var _regexEnabled=true;var _arguments="arguments";var _undef="undefined";var getType=function(){var a=Object.prototype.toString,b={},c={1:"element",3:"textnode",9:"document",11:"fragment"},d="Arguments Array Boolean Date Document Element Error Fragment Function NodeList Null Number Object RegExp String TextNode Undefined Window".split(" ");for(var e=d.length;e--;){var f=d[e],g=window[f];if(g){try{b[a.call(new g)]=f.toLowerCase()}catch(h){}}}return function(d){return d==null&&(d===undefined?_undef:"null")||d.nodeType&&c[d.nodeType]||typeof d.length=="number"&&(d.callee&&_arguments||d.alert&&"window"||d.item&&"nodelist")||b[a.call(d)]}}();var isFunc=function(a){return getType(a)=="function"};var weaveOne=function(source,method,advice){var old=source[method];if(advice.type!=_intro&&!isFunc(old)){var oldObject=old;old=function(){var code=arguments.length>0?_arguments+"[0]":"";for(var i=1;i<arguments.length;i++){code+=","+_arguments+"["+i+"]"}return eval("oldObject("+code+");")}}var aspect;if(advice.type==_after||advice.type==_afterThrow||advice.type==_afterFinally)aspect=function(){var a,b=null;try{a=old.apply(this,arguments)}catch(c){b=c}if(advice.type==_after)if(b==null)a=advice.value.apply(this,[a,method]);else throw b;else if(advice.type==_afterThrow&&b!=null)a=advice.value.apply(this,[b,method]);else if(advice.type==_afterFinally)a=advice.value.apply(this,[a,b,method]);return a};else if(advice.type==_before)aspect=function(){advice.value.apply(this,[arguments,method]);return old.apply(this,arguments)};else if(advice.type==_intro)aspect=function(){return advice.value.apply(this,arguments)};else if(advice.type==_around){aspect=function(){var a={object:this,args:Array.prototype.slice.call(arguments)};return advice.value.apply(a.object,[{arguments:a.args,method:method,proceed:function(){return old.apply(a.object,a.args)}}])}}aspect.unweave=function(){source[method]=old;pointcut=source=aspect=old=null};source[method]=aspect;return aspect};var search=function(a,b,c){var d=[];for(var e in a){var f=null;try{f=a[e]}catch(g){}if(f!=null&&e.match(b.method)&&isFunc(f))d[d.length]={source:a,method:e,advice:c}}return d};var weave=function(a,b){var c=typeof a.target.prototype!=_undef?a.target.prototype:a.target;var d=[];if(b.type!=_intro&&typeof c[a.method]==_undef){var e=search(a.target,a,b);if(e.length==0)e=search(c,a,b);for(var f in e)d[d.length]=weaveOne(e[f].source,e[f].method,e[f].advice)}else{d[0]=weaveOne(c,a.method,b)}return _regexEnabled?d:d[0]};aop={after:function(a,b){return weave(a,{type:_after,value:b})},afterThrow:function(a,b){return weave(a,{type:_afterThrow,value:b})},afterFinally:function(a,b){return weave(a,{type:_afterFinally,value:b})},before:function(a,b){return weave(a,{type:_before,value:b})},around:function(a,b){return weave(a,{type:_around,value:b})},introduction:function(a,b){return weave(a,{type:_intro,value:b})},setup:function(a){_regexEnabled=a.regexMatch}}})();if(dnt_config.ifdnt!=="1"||navigator.doNotTrack==="yes"){var mode=dnt_config.mode;var list=[];list["black"]=dnt_config.black;list["white"]=dnt_config.white;aop.around({target:document,method:"write"},function(a){if(a.arguments[0].search(/img|script/i)!==-1){if(sanitizer(a.arguments[0])===true){a.arguments[0]=a.arguments[0].replace(/</g,"<!-- ").replace(/>/g," -->")}}return a.proceed()});scriptParent=document.getElementsByTagName("script")[0].parentNode;if(scriptParent.tagName.toLowerCase!=="head"){head=document.getElementsByTagName("head")[0];aop_around(head,"insertBefore");aop_around(head,"appendChild")}aop_around(scriptParent,"insertBefore");aop_around(scriptParent,"appendChild");var a2a_config=a2a_config||{};a2a_config.no_3p=1;var addthis_config={data_use_cookies:false};var _gaq=_gaq||[];_gaq.push(["_gat._anonymizeIp"])}
1
+ function sanitizer(a){a=a.toLowerCase();if(mode==="blacklist"){for(x in list["black"]){if(a.indexOf(list["black"][x].toLowerCase())!==-1){a=true;break}}}else{for(x in list["white"]){if(a.indexOf(list["white"][x].toLowerCase())!==-1){tmpS=false;break}else{tmpS=true}}if(tmpS===true)a=tmpS}return a}function aop_around(a,b){aop.around({target:a,method:b},function(a){if(typeof a.arguments[0].src==="string"&&(a.arguments[0].tagName.toLowerCase()==="script"||a.arguments[0].tagName.toLowerCase()==="img"||a.arguments[0].tagName.toLowerCase()==="iframe")){if(sanitizer(a.arguments[0].src)===true){a.arguments[0].src="javascript:void(0)"}}return a.proceed()})}(function(){var _after=1;var _afterThrow=2;var _afterFinally=3;var _before=4;var _around=5;var _intro=6;var _regexEnabled=true;var _arguments="arguments";var _undef="undefined";var getType=function(){var a=Object.prototype.toString,b={},c={1:"element",3:"textnode",9:"document",11:"fragment"},d="Arguments Array Boolean Date Document Element Error Fragment Function NodeList Null Number Object RegExp String TextNode Undefined Window".split(" ");for(var e=d.length;e--;){var f=d[e],g=window[f];if(g){try{b[a.call(new g)]=f.toLowerCase()}catch(h){}}}return function(d){return d==null&&(d===undefined?_undef:"null")||d.nodeType&&c[d.nodeType]||typeof d.length=="number"&&(d.callee&&_arguments||d.alert&&"window"||d.item&&"nodelist")||b[a.call(d)]}}();var isFunc=function(a){return getType(a)=="function"};var weaveOne=function(source,method,advice){var old=source[method];if(advice.type!=_intro&&!isFunc(old)){var oldObject=old;old=function(){var code=arguments.length>0?_arguments+"[0]":"";for(var i=1;i<arguments.length;i++){code+=","+_arguments+"["+i+"]"}return eval("oldObject("+code+");")}}var aspect;if(advice.type==_after||advice.type==_afterThrow||advice.type==_afterFinally)aspect=function(){var a,b=null;try{a=old.apply(this,arguments)}catch(c){b=c}if(advice.type==_after)if(b==null)a=advice.value.apply(this,[a,method]);else throw b;else if(advice.type==_afterThrow&&b!=null)a=advice.value.apply(this,[b,method]);else if(advice.type==_afterFinally)a=advice.value.apply(this,[a,b,method]);return a};else if(advice.type==_before)aspect=function(){advice.value.apply(this,[arguments,method]);return old.apply(this,arguments)};else if(advice.type==_intro)aspect=function(){return advice.value.apply(this,arguments)};else if(advice.type==_around){aspect=function(){var a={object:this,args:Array.prototype.slice.call(arguments)};return advice.value.apply(a.object,[{arguments:a.args,method:method,proceed:function(){return old.apply(a.object,a.args)}}])}}aspect.unweave=function(){source[method]=old;pointcut=source=aspect=old=null};source[method]=aspect;return aspect};var search=function(a,b,c){var d=[];for(var e in a){var f=null;try{f=a[e]}catch(g){}if(f!=null&&e.match(b.method)&&isFunc(f))d[d.length]={source:a,method:e,advice:c}}return d};var weave=function(a,b){var c=typeof a.target.prototype!=_undef?a.target.prototype:a.target;var d=[];if(b.type!=_intro&&typeof c[a.method]==_undef){var e=search(a.target,a,b);if(e.length==0)e=search(c,a,b);for(var f in e)d[d.length]=weaveOne(e[f].source,e[f].method,e[f].advice)}else{d[0]=weaveOne(c,a.method,b)}return _regexEnabled?d:d[0]};aop={after:function(a,b){return weave(a,{type:_after,value:b})},afterThrow:function(a,b){return weave(a,{type:_afterThrow,value:b})},afterFinally:function(a,b){return weave(a,{type:_afterFinally,value:b})},before:function(a,b){return weave(a,{type:_before,value:b})},around:function(a,b){return weave(a,{type:_around,value:b})},introduction:function(a,b){return weave(a,{type:_intro,value:b})},setup:function(a){_regexEnabled=a.regexMatch}}})();if(dnt_config.ifdnt!=="1"||navigator.doNotTrack==="yes"){var mode=dnt_config.mode;var list=[];list["black"]=dnt_config.black;list["white"]=dnt_config.white;aop.around({target:document,method:"write"},function(a){if(a.arguments[0].search(/img|script|iframe/i)!==-1){if(sanitizer(a.arguments[0])===true){a.arguments[0]=a.arguments[0].replace(/</g,"<!-- ").replace(/>/g," -->")}}return a.proceed()});scriptParent=document.getElementsByTagName("script")[0].parentNode;if(scriptParent.tagName.toLowerCase!=="head"){head=document.getElementsByTagName("head")[0];aop_around(head,"insertBefore");aop_around(head,"appendChild")}aop_around(scriptParent,"insertBefore");aop_around(scriptParent,"appendChild");var a2a_config=a2a_config||{};a2a_config.no_3p=1;var addthis_config={data_use_cookies:false};var _gaq=_gaq||[];_gaq.push(["_gat._anonymizeIp"])}
external/donottrack.js CHANGED
@@ -404,7 +404,7 @@
404
  function aop_around(myTarget, myMethod) {
405
  aop.around( {target: myTarget, method: myMethod },
406
  function(invocation) {
407
- if ((typeof(invocation.arguments[0].src)==='string')&&((invocation.arguments[0].tagName.toLowerCase()==='script')||(invocation.arguments[0].tagName.toLowerCase()==='img'))) {
408
  if (sanitizer(invocation.arguments[0].src)===true) {
409
  invocation.arguments[0].src='javascript:void(0)';
410
  }
@@ -446,7 +446,7 @@ if ((dnt_config.ifdnt!=="1")||(navigator.doNotTrack==="yes")) {
446
  // for document.write, has to be sanitized differently from others
447
  aop.around( {target: document, method: 'write' },
448
  function(invocation) {
449
- if (invocation.arguments[0].search(/img|script/i)!==-1) {
450
  if (sanitizer(invocation.arguments[0])===true) {
451
  invocation.arguments[0]=invocation.arguments[0].replace(/</g,'<!-- ').replace(/>/g,' -->');
452
  }
404
  function aop_around(myTarget, myMethod) {
405
  aop.around( {target: myTarget, method: myMethod },
406
  function(invocation) {
407
+ if ((typeof(invocation.arguments[0].src)==='string')&&((invocation.arguments[0].tagName.toLowerCase()==='script')||(invocation.arguments[0].tagName.toLowerCase()==='img')||(invocation.arguments[0].tagName.toLowerCase()==='iframe'))) {
408
  if (sanitizer(invocation.arguments[0].src)===true) {
409
  invocation.arguments[0].src='javascript:void(0)';
410
  }
446
  // for document.write, has to be sanitized differently from others
447
  aop.around( {target: document, method: 'write' },
448
  function(invocation) {
449
+ if (invocation.arguments[0].search(/img|script|iframe/i)!==-1) {
450
  if (sanitizer(invocation.arguments[0])===true) {
451
  invocation.arguments[0]=invocation.arguments[0].replace(/</g,'<!-- ').replace(/>/g,' -->');
452
  }
lyte/lyte-min.js CHANGED
@@ -1 +1 @@
1
- function loadScript(a){scr=doc.createElement("script");scr.src=a;scr.type="text/javascript";doc.getElementsByTagName("head")[0].appendChild(scr)}function setStyle(a,b){if(typeof a.setAttribute==="function")a.setAttribute("style",b);else if(typeof a.style.setAttribute==="object")a.style.setAttribute("cssText",b)}function drawTitle(a,b){p=doc.getElementById(a);c=doc.createElement("div");c.className="tC";p.appendChild(c);setStyle(c,"margin:-"+(p.clientHeight/2+15)+"px 5px;");t=doc.createElement("div");t.className="tT";c.appendChild(t);t.innerHTML=b}function parsePL(a){thumb=a.feed.entry[0].media$group.media$thumbnail[1].url;idu=a.feed.id.$t;id="lyte_"+idu.substring(idu.length-16);title="Playlist: "+a.feed.title.$t;pl=doc.getElementById(id);pH=pl.style.height;pW=pl.style.width;if(scheme=="https"&&thumb.indexOf("https"==-1)){thumb=thumb.replace("http://","https://")}setStyle(pl,"height:"+pH+";width:"+pW+";background:url('"+thumb+"') no-repeat scroll center -10px rgb(0, 0, 0); background-size:contain;");drawTitle(id,title)}function parseV(a){title=a.entry.title.$t;idu=a.entry.id.$t;id="lyte_"+idu.substring(idu.length-11);drawTitle(id,title)}function plaYT(){this.onclick="";vid=this.id.substring(4);if(this.className.indexOf("hidef")===-1){hidef=0}else{hidef=1}if(this.className.indexOf("playlist")===-1){eU=scheme+"://www.youtube.com/embed/"+vid}else{eU=scheme+"://www.youtube.com/embed/p/"+vid}this.innerHTML='<iframe class="youtube-player" type="text/html" width="'+this.clientWidth+'" height="'+this.clientHeight+'" src="'+eU+"?autoplay=1&rel=0&egm=0&iv_load_policy=3&probably_logged_in=false&hd="+hidef+'" frameborder="0"></iframe>'}function lyte(){lytes=getElementsByClassName("lyte","div");for(var a=0;a<lytes.length;a++){lyte_id=lytes[a].id;vid=lyte_id.substring(4);p=doc.getElementById(lyte_id);p.className+=" lP";pW=p.clientWidth;pH=p.clientHeight;pl=doc.createElement("div");p.appendChild(pl);p.onclick=plaYT;pl.id="lyte_"+vid;pl.className="pL";if(p.className.indexOf("audio")!==-1){setStyle(pl,"height:"+pH+"px;width:"+pW);pl.innerHTML='<img src="'+bU+"controls-"+pW+'.png" width="100%" id="ctrl" alt="" style="max-width:'+pW+'px;"/>'}else if(p.className.indexOf("playlist")!==-1){setStyle(pl,"height:"+pH+"px;width:"+pW+"px;");pl.innerHTML='<img src="'+bU+'play.png" alt="Click to play this playlist" style="margin-top:'+(pH/2-30)+'px;opacity:0.7;" onmouseover="this.style.opacity=1;" onmouseout="this.style.opacity=0.8;"/><img src="'+bU+"controls-"+pW+'.png" width="100%" id="ctrl" alt="" style="max-width:'+pW+'px;"/>';jsonUrl=scheme+"://gdata.youtube.com/feeds/api/playlists/"+vid+"?v=2&alt=json-in-script&callback=parsePL&fields=id,title,entry";loadScript(jsonUrl)}else{setStyle(pl,"height:"+pH+"px;width:"+pW+"px;background:url('"+scheme+"://img.youtube.com/vi/"+vid+"/0.jpg') no-repeat scroll center -10px rgb(0, 0, 0);background-size:contain;");pl.innerHTML='<img src="'+bU+'play.png" alt="Click to play this video" style="margin-top:'+(pH/2-30)+'px;opacity:0.7;" onmouseover="this.style.opacity=1;" onmouseout="this.style.opacity=0.8;"/><img src="'+bU+"controls-"+pW+'.png" width="100%" id="ctrl" alt="" style="max-width:'+pW+'px;"/>';if(p.className.indexOf("widget")===-1){jsonUrl=scheme+"://gdata.youtube.com/feeds/api/videos/"+vid+"?fields=id,title&alt=json-in-script&callback=parseV";loadScript(jsonUrl)}}}}var doc=document;var cI="lytecss";var myUrl=doc.getElementById("lytescr").src;var bU=myUrl.substring(0,myUrl.lastIndexOf("/")+1);scheme="http";if(myUrl.indexOf("https")!=-1){scheme+="s"}if(!doc.getElementById(cI)){lk=doc.createElement("link");lk.id=cI;lk.rel="stylesheet";lk.type="text/css";lk.href=bU+"lyte.css";doc.getElementsByTagName("head")[0].appendChild(lk)}var getElementsByClassName=function(a,b,c){if(doc.getElementsByClassName){getElementsByClassName=function(a,b,c){c=c||doc;var d=c.getElementsByClassName(a),e=b?new RegExp("\\b"+b+"\\b","i"):null,f=[],g;for(var h=0,i=d.length;h<i;h+=1){g=d[h];if(!e||e.test(g.nodeName)){f.push(g)}}return f}}else if(doc.evaluate){getElementsByClassName=function(a,b,c){b=b||"*";c=c||doc;var d=a.split(" "),e="",f="http://www.w3.org/1999/xhtml",g=doc.documentElement.namespaceURI===f?f:null,h=[],i,j;for(var k=0,l=d.length;k<l;k+=1){e+="[contains(concat(' ', @class, ' '), ' "+d[k]+" ')]"}try{i=doc.evaluate(".//"+b+e,c,g,0,null)}catch(m){i=doc.evaluate(".//"+b+e,c,null,0,null)}while(j=i.iterateNext()){h.push(j)}return h}}else{getElementsByClassName=function(a,b,c){b=b||"*";c=c||doc;var d=a.split(" "),e=[],f=b==="*"&&c.all?c.all:c.getElementsByTagName(b),g,h=[],i;for(var j=0,k=d.length;j<k;j+=1){e.push(new RegExp("(^|\\s)"+d[j]+"(\\s|$)"))}for(var l=0,m=f.length;l<m;l+=1){g=f[l];i=false;for(var n=0,o=e.length;n<o;n+=1){i=e[n].test(g.className);if(!i){break}}if(i){h.push(g)}}return h}}return getElementsByClassName(a,b,c)};lyte()
1
+ function loadSC(a){scr=d.createElement("script");scr.src=a;scr.type="text/javascript";d.getElementsByTagName("head")[0].appendChild(scr)}function setST(a,b){if(typeof a.setAttribute==="function")a.setAttribute("style",b);else if(typeof a.style.setAttribute==="object")a.style.setAttribute("cssText",b)}function drawT(a,b){p=d.getElementById(a);c=d.createElement("div");c.className="tC";p.appendChild(c);setST(c,"margin:-"+(p.clientHeight/2+15)+"px 5px;");t=d.createElement("div");t.className="tT";c.appendChild(t);t.innerHTML=b}function parsePL(a){thumb=a.feed.entry[0].media$group.media$thumbnail[1].url;idu=a.feed.id.$t;id="lyte_"+idu.substring(idu.length-16);title="Playlist: "+a.feed.title.$t;pl=d.getElementById(id);pH=pl.style.height;pW=pl.style.width;if(scheme=="https"&&thumb.indexOf("https"==-1)){thumb=thumb.replace("http://","https://")}setST(pl,"height:"+pH+";width:"+pW+";background:url('"+thumb+"') no-repeat scroll center -10px rgb(0, 0, 0); background-size:contain;");drawT(id,title)}function parseV(a){tI=a.entry.title.$t;idu=a.entry.id.$t;id="lyte_"+idu.substring(idu.length-11);drawT(id,tI)}function plaYT(){tH=this;tH.onclick="";vid=tH.id.substring(4);if(tH.className.indexOf("hidef")===-1){hidef=0}else{hidef=1}if(tH.className.indexOf("playlist")===-1){eU=scheme+"://www.youtube.com/embed/"+vid}else{eU=scheme+"://www.youtube.com/embed/p/"+vid}qsa=getQ(vid);tH.innerHTML='<iframe class="youtube-player" type="text/html" width="'+tH.clientWidth+'" height="'+tH.clientHeight+'" src="'+eU+"?autoplay=1&wmode=opaque&rel=0&egm=0&iv_load_policy=3&probably_logged_in=false&hd="+hidef+qsa+'" frameborder="0"></iframe>'}function getQ(a){qsa="";if(typeof w.lst!=="undefined"&&typeof w.lst[a]!=="undefined")qsa=w.lst[a];return qsa}function lyte(){lytes=getElementsByClassName("lyte","div");for(var a=0;a<lytes.length;a++){lyte_id=lytes[a].id;vid=lyte_id.substring(4);p=d.getElementById(lyte_id);p.className+=" lP";pW=p.clientWidth;pH=p.clientHeight;pl=d.createElement("div");p.appendChild(pl);p.onclick=plaYT;pl.id="lyte_"+vid;pl.className="pL";qsa=getQ(vid);if(p.className.indexOf("audio")!==-1){setST(pl,"height:"+pH+"px;width:"+pW);pl.innerHTML='<img src="'+bU+"controls-"+pW+'.png" width="100%" id="ctrl" alt="" style="max-width:'+pW+'px;"/>'}else if(p.className.indexOf("playlist")!==-1){setST(pl,"height:"+pH+"px;width:"+pW+"px;");pl.innerHTML='<img src="'+bU+'play.png" alt="Click to play this playlist" style="margin-top:'+(pH/2-30)+'px;opacity:0.7;" onmouseover="this.style.opacity=1;" onmouseout="this.style.opacity=0.8;"/><img src="'+bU+"controls-"+pW+'.png" width="100%" id="ctrl" alt="" style="max-width:'+pW+'px;"/>';jsonUrl=scheme+"://gdata.youtube.com/feeds/api/playlists/"+vid+"?v=2&alt=json-in-script&callback=parsePL&fields=id,title,entry";loadSC(jsonUrl)}else{setST(pl,"height:"+pH+"px;width:"+pW+"px;background:url('"+scheme+"://img.youtube.com/vi/"+vid+"/0.jpg') no-repeat scroll center -10px rgb(0, 0, 0);background-size:contain;");pl.innerHTML='<img src="'+bU+'play.png" alt="Click to play this video" style="margin-top:'+(pH/2-30)+'px;opacity:0.7;" onmouseover="this.style.opacity=1;" onmouseout="this.style.opacity=0.8;"/><img src="'+bU+"controls-"+pW+'.png" width="100%" id="ctrl" alt="" style="max-width:'+pW+'px;"/>';if(p.className.indexOf("widget")===-1&&qsa.indexOf("showinfo=0")===-1){jsonUrl=scheme+"://gdata.youtube.com/feeds/api/videos/"+vid+"?fields=id,title&alt=json-in-script&callback=parseV";loadSC(jsonUrl)}}}}var d=document;var cI="lcss";var w=window;var myUrl=d.getElementById("lytescr").src;var bU=myUrl.substring(0,myUrl.lastIndexOf("/")+1);scheme="http";if(myUrl.indexOf("https")!=-1){scheme+="s"}if(!d.getElementById(cI)){lk=d.createElement("link");lk.id=cI;lk.rel="stylesheet";lk.type="text/css";lk.href=bU+"lyte.css";d.getElementsByTagName("head")[0].appendChild(lk)}var getElementsByClassName=function(a,b,c){if(d.getElementsByClassName){getElementsByClassName=function(a,b,c){c=c||d;var e=c.getElementsByClassName(a),f=b?new RegExp("\\b"+b+"\\b","i"):null,g=[],h;for(var i=0,j=e.length;i<j;i+=1){h=e[i];if(!f||f.test(h.nodeName)){g.push(h)}}return g}}else if(d.evaluate){getElementsByClassName=function(a,b,c){b=b||"*";c=c||d;var e=a.split(" "),f="",g="http://www.w3.org/1999/xhtml",h=d.documentElement.namespaceURI===g?g:null,i=[],j,k;for(var l=0,m=e.length;l<m;l+=1){f+="[contains(concat(' ', @class, ' '), ' "+e[l]+" ')]"}try{j=d.evaluate(".//"+b+f,c,h,0,null)}catch(n){j=d.evaluate(".//"+b+f,c,null,0,null)}while(k=j.iterateNext()){i.push(k)}return i}}else{getElementsByClassName=function(a,b,c){b=b||"*";c=c||d;var e=a.split(" "),f=[],g=b==="*"&&c.all?c.all:c.getElementsByTagName(b),h,i=[],j;for(var k=0,l=e.length;k<l;k+=1){f.push(new RegExp("(^|\\s)"+e[k]+"(\\s|$)"))}for(var m=0,n=g.length;m<n;m+=1){h=g[m];j=false;for(var o=0,p=f.length;o<p;o+=1){j=f[o].test(h.className);if(!j){break}}if(j){i.push(h)}}return i}}return getElementsByClassName(a,b,c)};lyte()
lyte/lyte.js CHANGED
@@ -1,19 +1,21 @@
1
- var doc = document;
2
- var cI = 'lytecss';
 
 
 
3
 
4
- var myUrl = doc.getElementById('lytescr').src;
5
  var bU = myUrl.substring(0,myUrl.lastIndexOf('/')+1);
6
 
7
  scheme="http";
8
  if (myUrl.indexOf('https')!=-1) {scheme+="s";}
9
 
10
- if (!doc.getElementById(cI)) {
11
- lk = doc.createElement('link');
12
  lk.id = cI;
13
  lk.rel = 'stylesheet';
14
  lk.type = 'text/css';
15
  lk.href = bU + 'lyte.css';
16
- doc.getElementsByTagName('head')[0].appendChild(lk);
17
  }
18
 
19
  function lyte() {
@@ -21,59 +23,70 @@ function lyte() {
21
  for (var i = 0; i < lytes.length; i++) {
22
  lyte_id = lytes[i].id;
23
  vid = lyte_id.substring(4);
24
- p = doc.getElementById(lyte_id);
25
  p.className += " lP";
26
  pW = p.clientWidth;
27
  pH = p.clientHeight;
28
- pl = doc.createElement('div');
29
  p.appendChild(pl);
30
  p.onclick = plaYT;
31
  pl.id = "lyte_" + vid;
32
  pl.className = "pL";
33
 
 
 
34
  if (p.className.indexOf('audio') !== -1) {
35
- setStyle(pl, 'height:' + pH + 'px;width:' + pW);
36
  pl.innerHTML = "<img src=\"" + bU + "controls-" + pW + ".png\" width=\"100%\" id=\"ctrl\" alt=\"\" style=\"max-width:" + pW + "px;\"/>";
37
  } else if (p.className.indexOf('playlist') !== -1){
38
- setStyle(pl, 'height:' + pH + 'px;width:' + pW + 'px;');
39
  pl.innerHTML = "<img src=\"" + bU + "play.png\" alt=\"Click to play this playlist\" style=\"margin-top:" + ((pH / 2) - 30) + "px;opacity:0.7;\" onmouseover=\"this.style.opacity=1;\" onmouseout=\"this.style.opacity=0.8;\"/><img src=\"" + bU + "controls-" + pW + ".png\" width=\"100%\" id=\"ctrl\" alt=\"\" style=\"max-width:" + pW + "px;\"/>";
40
  jsonUrl = scheme+"://gdata.youtube.com/feeds/api/playlists/"+ vid +"?v=2&alt=json-in-script&callback=parsePL&fields=id,title,entry"
41
- loadScript(jsonUrl)
42
  } else {
43
- setStyle(pl, "height:" + pH + "px;width:" + pW + "px;background:url('" + scheme + "://img.youtube.com/vi/" + vid + "/0.jpg') no-repeat scroll center -10px rgb(0, 0, 0);background-size:contain;");
44
  pl.innerHTML = "<img src=\"" + bU + "play.png\" alt=\"Click to play this video\" style=\"margin-top:" + ((pH / 2) - 30) + "px;opacity:0.7;\" onmouseover=\"this.style.opacity=1;\" onmouseout=\"this.style.opacity=0.8;\"/><img src=\"" + bU + "controls-" + pW + ".png\" width=\"100%\" id=\"ctrl\" alt=\"\" style=\"max-width:" + pW + "px;\"/>";
45
- if (p.className.indexOf('widget') === -1) {
46
  jsonUrl = scheme+"://gdata.youtube.com/feeds/api/videos/" + vid + "?fields=id,title&alt=json-in-script&callback=parseV";
47
- loadScript(jsonUrl)
48
  }
49
  }
50
  }
51
  }
52
 
 
 
 
 
 
 
53
  function plaYT() {
54
- this.onclick = "";
55
- vid=this.id.substring(4);
 
56
 
57
- if (this.className.indexOf("hidef") === -1) {
58
  hidef=0;
59
  } else {
60
  hidef=1;
61
  }
62
 
63
- if (this.className.indexOf("playlist") === -1) {
64
  eU=scheme+"://www.youtube.com/embed/" + vid
65
  } else {
66
  eU=scheme+"://www.youtube.com/embed/p/" + vid
67
  }
68
 
69
- this.innerHTML="<iframe class=\"youtube-player\" type=\"text/html\" width=\"" + this.clientWidth + "\" height=\"" + this.clientHeight + "\" src=\""+eU+"?autoplay=1&amp;rel=0&amp;egm=0&amp;iv_load_policy=3&amp;probably_logged_in=false&amp;hd="+hidef+"\" frameborder=\"0\"></iframe>"
 
 
70
  }
71
 
72
  function parseV(r) {
73
- title = r.entry.title.$t;
74
  idu = r.entry.id.$t;
75
  id = "lyte_" + idu.substring(idu.length - 11);
76
- drawTitle(id,title);
77
  }
78
 
79
  function parsePL(r) {
@@ -81,44 +94,44 @@ function parsePL(r) {
81
  idu=r.feed.id.$t
82
  id="lyte_"+idu.substring(idu.length - 16)
83
  title="Playlist: "+r.feed.title.$t
84
- pl=doc.getElementById(id)
85
  pH=pl.style.height;
86
  pW=pl.style.width;
87
 
88
  if ((scheme=="https")&&(thumb.indexOf('https'==-1))) {thumb=thumb.replace("http://","https://");}
89
 
90
- setStyle(pl, "height:" + pH + ";width:" + pW + ";background:url('" + thumb + "') no-repeat scroll center -10px rgb(0, 0, 0); background-size:contain;")
91
- drawTitle(id,title)
92
  }
93
 
94
- function drawTitle(id,title) {
95
- p = doc.getElementById(id);
96
- c = doc.createElement('div');
97
  c.className = "tC";
98
  p.appendChild(c);
99
- setStyle(c, "margin:-" + ((p.clientHeight / 2) + 15) + "px 5px;");
100
- t = doc.createElement('div');
101
  t.className = "tT";
102
  c.appendChild(t);
103
- t.innerHTML = title;
104
  }
105
 
106
- function setStyle(e, s) {
107
  if (typeof e.setAttribute === "function") e.setAttribute('style', s);
108
  else if (typeof e.style.setAttribute === "object") e.style.setAttribute('cssText', s)
109
  }
110
 
111
- function loadScript(url) {
112
- scr = doc.createElement('script');
113
  scr.src = url;
114
  scr.type = 'text/javascript';
115
- doc.getElementsByTagName('head')[0].appendChild(scr)
116
  }
117
 
118
  var getElementsByClassName = function (className, tag, elm) {
119
- if (doc.getElementsByClassName) {
120
  getElementsByClassName = function (className, tag, elm) {
121
- elm = elm || doc;
122
  var elements = elm.getElementsByClassName(className),
123
  nodeName = (tag) ? new RegExp("\\b" + tag + "\\b", "i") : null,
124
  returnElements = [],
@@ -131,23 +144,23 @@ var getElementsByClassName = function (className, tag, elm) {
131
  }
132
  return returnElements
133
  }
134
- } else if (doc.evaluate) {
135
  getElementsByClassName = function (className, tag, elm) {
136
  tag = tag || "*";
137
- elm = elm || doc;
138
  var classes = className.split(" "),
139
  classesToCheck = "",
140
  xhtmlNamespace = "http://www.w3.org/1999/xhtml",
141
- namespaceResolver = (doc.documentElement.namespaceURI === xhtmlNamespace) ? xhtmlNamespace : null,
142
  returnElements = [],
143
  elements, node;
144
  for (var j = 0, jl = classes.length; j < jl; j += 1) {
145
  classesToCheck += "[contains(concat(' ', @class, ' '), ' " + classes[j] + " ')]"
146
  }
147
  try {
148
- elements = doc.evaluate(".//" + tag + classesToCheck, elm, namespaceResolver, 0, null)
149
  } catch (e) {
150
- elements = doc.evaluate(".//" + tag + classesToCheck, elm, null, 0, null)
151
  }
152
  while ((node = elements.iterateNext())) {
153
  returnElements.push(node)
@@ -157,7 +170,7 @@ var getElementsByClassName = function (className, tag, elm) {
157
  } else {
158
  getElementsByClassName = function (className, tag, elm) {
159
  tag = tag || "*";
160
- elm = elm || doc;
161
  var classes = className.split(" "),
162
  classesToCheck = [],
163
  elements = (tag === "*" && elm.all) ? elm.all : elm.getElementsByTagName(tag),
1
+ var d = document;
2
+ var cI = 'lcss';
3
+ var w = window;
4
+
5
+ var myUrl = d.getElementById('lytescr').src;
6
 
 
7
  var bU = myUrl.substring(0,myUrl.lastIndexOf('/')+1);
8
 
9
  scheme="http";
10
  if (myUrl.indexOf('https')!=-1) {scheme+="s";}
11
 
12
+ if (!d.getElementById(cI)) {
13
+ lk = d.createElement('link');
14
  lk.id = cI;
15
  lk.rel = 'stylesheet';
16
  lk.type = 'text/css';
17
  lk.href = bU + 'lyte.css';
18
+ d.getElementsByTagName('head')[0].appendChild(lk);
19
  }
20
 
21
  function lyte() {
23
  for (var i = 0; i < lytes.length; i++) {
24
  lyte_id = lytes[i].id;
25
  vid = lyte_id.substring(4);
26
+ p = d.getElementById(lyte_id);
27
  p.className += " lP";
28
  pW = p.clientWidth;
29
  pH = p.clientHeight;
30
+ pl = d.createElement('div');
31
  p.appendChild(pl);
32
  p.onclick = plaYT;
33
  pl.id = "lyte_" + vid;
34
  pl.className = "pL";
35
 
36
+ qsa=getQ(vid);
37
+
38
  if (p.className.indexOf('audio') !== -1) {
39
+ setST(pl, 'height:' + pH + 'px;width:' + pW);
40
  pl.innerHTML = "<img src=\"" + bU + "controls-" + pW + ".png\" width=\"100%\" id=\"ctrl\" alt=\"\" style=\"max-width:" + pW + "px;\"/>";
41
  } else if (p.className.indexOf('playlist') !== -1){
42
+ setST(pl, 'height:' + pH + 'px;width:' + pW + 'px;');
43
  pl.innerHTML = "<img src=\"" + bU + "play.png\" alt=\"Click to play this playlist\" style=\"margin-top:" + ((pH / 2) - 30) + "px;opacity:0.7;\" onmouseover=\"this.style.opacity=1;\" onmouseout=\"this.style.opacity=0.8;\"/><img src=\"" + bU + "controls-" + pW + ".png\" width=\"100%\" id=\"ctrl\" alt=\"\" style=\"max-width:" + pW + "px;\"/>";
44
  jsonUrl = scheme+"://gdata.youtube.com/feeds/api/playlists/"+ vid +"?v=2&alt=json-in-script&callback=parsePL&fields=id,title,entry"
45
+ loadSC(jsonUrl)
46
  } else {
47
+ setST(pl, "height:" + pH + "px;width:" + pW + "px;background:url('" + scheme + "://img.youtube.com/vi/" + vid + "/0.jpg') no-repeat scroll center -10px rgb(0, 0, 0);background-size:contain;");
48
  pl.innerHTML = "<img src=\"" + bU + "play.png\" alt=\"Click to play this video\" style=\"margin-top:" + ((pH / 2) - 30) + "px;opacity:0.7;\" onmouseover=\"this.style.opacity=1;\" onmouseout=\"this.style.opacity=0.8;\"/><img src=\"" + bU + "controls-" + pW + ".png\" width=\"100%\" id=\"ctrl\" alt=\"\" style=\"max-width:" + pW + "px;\"/>";
49
+ if ((p.className.indexOf('widget') === -1) && (qsa.indexOf('showinfo=0') === -1)) {
50
  jsonUrl = scheme+"://gdata.youtube.com/feeds/api/videos/" + vid + "?fields=id,title&alt=json-in-script&callback=parseV";
51
+ loadSC(jsonUrl)
52
  }
53
  }
54
  }
55
  }
56
 
57
+ function getQ(v) {
58
+ qsa="";
59
+ if ((typeof w.lst !== 'undefined')&&(typeof w.lst[v] !== 'undefined')) qsa=w.lst[v];
60
+ return qsa;
61
+ }
62
+
63
  function plaYT() {
64
+ tH=this;
65
+ tH.onclick = "";
66
+ vid=tH.id.substring(4);
67
 
68
+ if (tH.className.indexOf("hidef") === -1) {
69
  hidef=0;
70
  } else {
71
  hidef=1;
72
  }
73
 
74
+ if (tH.className.indexOf("playlist") === -1) {
75
  eU=scheme+"://www.youtube.com/embed/" + vid
76
  } else {
77
  eU=scheme+"://www.youtube.com/embed/p/" + vid
78
  }
79
 
80
+ qsa=getQ(vid);
81
+
82
+ tH.innerHTML="<iframe class=\"youtube-player\" type=\"text/html\" width=\"" + tH.clientWidth + "\" height=\"" + tH.clientHeight + "\" src=\""+eU+"?autoplay=1&amp;wmode=opaque&amp;rel=0&amp;egm=0&amp;iv_load_policy=3&amp;probably_logged_in=false&amp;hd="+hidef+qsa+"\" frameborder=\"0\"></iframe>"
83
  }
84
 
85
  function parseV(r) {
86
+ tI = r.entry.title.$t;
87
  idu = r.entry.id.$t;
88
  id = "lyte_" + idu.substring(idu.length - 11);
89
+ drawT(id,tI);
90
  }
91
 
92
  function parsePL(r) {
94
  idu=r.feed.id.$t
95
  id="lyte_"+idu.substring(idu.length - 16)
96
  title="Playlist: "+r.feed.title.$t
97
+ pl=d.getElementById(id)
98
  pH=pl.style.height;
99
  pW=pl.style.width;
100
 
101
  if ((scheme=="https")&&(thumb.indexOf('https'==-1))) {thumb=thumb.replace("http://","https://");}
102
 
103
+ setST(pl, "height:" + pH + ";width:" + pW + ";background:url('" + thumb + "') no-repeat scroll center -10px rgb(0, 0, 0); background-size:contain;")
104
+ drawT(id,title)
105
  }
106
 
107
+ function drawT(id,tI) {
108
+ p = d.getElementById(id);
109
+ c = d.createElement('div');
110
  c.className = "tC";
111
  p.appendChild(c);
112
+ setST(c, "margin:-" + ((p.clientHeight / 2) + 15) + "px 5px;");
113
+ t = d.createElement('div');
114
  t.className = "tT";
115
  c.appendChild(t);
116
+ t.innerHTML = tI;
117
  }
118
 
119
+ function setST(e, s) {
120
  if (typeof e.setAttribute === "function") e.setAttribute('style', s);
121
  else if (typeof e.style.setAttribute === "object") e.style.setAttribute('cssText', s)
122
  }
123
 
124
+ function loadSC(url) {
125
+ scr = d.createElement('script');
126
  scr.src = url;
127
  scr.type = 'text/javascript';
128
+ d.getElementsByTagName('head')[0].appendChild(scr)
129
  }
130
 
131
  var getElementsByClassName = function (className, tag, elm) {
132
+ if (d.getElementsByClassName) {
133
  getElementsByClassName = function (className, tag, elm) {
134
+ elm = elm || d;
135
  var elements = elm.getElementsByClassName(className),
136
  nodeName = (tag) ? new RegExp("\\b" + tag + "\\b", "i") : null,
137
  returnElements = [],
144
  }
145
  return returnElements
146
  }
147
+ } else if (d.evaluate) {
148
  getElementsByClassName = function (className, tag, elm) {
149
  tag = tag || "*";
150
+ elm = elm || d;
151
  var classes = className.split(" "),
152
  classesToCheck = "",
153
  xhtmlNamespace = "http://www.w3.org/1999/xhtml",
154
+ namespaceResolver = (d.documentElement.namespaceURI === xhtmlNamespace) ? xhtmlNamespace : null,
155
  returnElements = [],
156
  elements, node;
157
  for (var j = 0, jl = classes.length; j < jl; j += 1) {
158
  classesToCheck += "[contains(concat(' ', @class, ' '), ' " + classes[j] + " ')]"
159
  }
160
  try {
161
+ elements = d.evaluate(".//" + tag + classesToCheck, elm, namespaceResolver, 0, null)
162
  } catch (e) {
163
+ elements = d.evaluate(".//" + tag + classesToCheck, elm, null, 0, null)
164
  }
165
  while ((node = elements.iterateNext())) {
166
  returnElements.push(node)
170
  } else {
171
  getElementsByClassName = function (className, tag, elm) {
172
  tag = tag || "*";
173
+ elm = elm || d;
174
  var classes = className.split(" "),
175
  classesToCheck = [],
176
  elements = (tag === "*" && elm.all) ? elm.all : elm.getElementsByTagName(tag),
readme.txt CHANGED
@@ -1,15 +1,15 @@
1
  === WP YouTube Lyte ===
2
  Contributors: futtta
3
- Tags: youtube, video, lyte, lite youtube embeds, html5 video, html5, widget, youtube audio, audio, playlist, youtube playlist, hd, performance, accessibility, sidebar
4
  Requires at least: 2.9
5
  Tested up to: 3.3
6
- Stable tag: 0.9.4
7
 
8
  "Lite YouTube Embeds" look like normal YouTube embeds but don't use Flash, thus reducing download size & page rendering time.
9
 
10
  == Description ==
11
 
12
- WP YouTube Lyte inserts "Lite YouTube Embeds" in your blog. These look and feel like normal embedded YouTube, but only call the actual "fat" Flash or HTML5-player when clicked on, thereby [reducing download size & rendering time substantially](http://blog.futtta.be/2010/08/30/the-state-of-wp-youtube-lyte/) when embedding YouTube occasionally and improving page performance dramatically when you've got multiple YouTube video's on one and the same page.
13
 
14
  Just add a YouTube-link for a video or [an entire playlist](http://blog.futtta.be/2011/10/11/wp-youtube-lyte-support-for-playlists-almost-included/) with "httpv" (or "httpa" to [embed YouTube's audio](http://blog.futtta.be/2011/04/19/audio-only-youtube-embedding-with-wp-youtube-lyte-0-7/) only) instead of "http" or add a Lyte widget to your sidebar and WP YouTube Lyte replaces that link with the correct performance-optimized code. When a visitor clicks the play-button, WP YouTube Lyte seamlessly initiates [YouTube's new embedded player](http://apiblog.youtube.com/2010/07/new-way-to-embed-youtube-videos.html). Some examples:
15
 
@@ -43,6 +43,12 @@ When playing, HTML5 video will not be visible for everyone (see requirements). I
43
  = Does WP YouTube Lyte protect my visitor's privacy? =
44
  As opposed to some of the [most important](http://blog.futtta.be/2010/12/15/wordpress-com-stats-trojan-horse-for-quantcast-tracking/) [plugins](http://blog.futtta.be/2010/01/22/add-to-any-removed-from-here/) there is no 3rd party tracking code in WP YouTube Lyte, but YouTube off course does see visitor requests coming in (see also the youtube-nocookie.com remark in Bugs/Issues below).
45
 
 
 
 
 
 
 
46
  = Can I use WP YouTube Lyte for a custom field? =
47
  As tested and confirmed by [rumultik.ru's Dimitri](http://rumultik.ru) (thanks for that man!), this indeed does work. Just pass the httpv url of such a field to lyte_parse like this:
48
  `if(function_exists('lyte_parse')) { echo lyte_parse($video); }`
@@ -62,8 +68,20 @@ and you're good to go!
62
  * Ask me for a feature you would like to see added
63
  * [Rate my plugin on wordpress.org](http://wordpress.org/extend/plugins/wp-youtube-lyte/), even if you think it stinks ;-)
64
 
 
 
 
 
65
  == Changelog ==
66
 
 
 
 
 
 
 
 
 
67
  = 0.9.4 =
68
  * security: WP YouTube Lyte now works entirely in https if your blog is running in https
69
  * performance (js/ page rendering): initiate the javascript a little later (at "load" instead of "DOMContentLoaded") to speed up page load (might need further optimizations)
1
  === WP YouTube Lyte ===
2
  Contributors: futtta
3
+ Tags: youtube, video, lyte, lite youtube embeds, html5 video, html5, widget, youtube audio, audio, playlist, youtube playlist, hd, performance, accessibility, sidebar, lazy load
4
  Requires at least: 2.9
5
  Tested up to: 3.3
6
+ Stable tag: 1.0.0
7
 
8
  "Lite YouTube Embeds" look like normal YouTube embeds but don't use Flash, thus reducing download size & page rendering time.
9
 
10
  == Description ==
11
 
12
+ WP YouTube Lyte allows you to "lazy load" your video's, by inserting "Lite YouTube Embeds". These look and feel like normal embedded YouTube, but only call the actual "fat" Flash or HTML5-player when clicked on, thereby [reducing download size & rendering time substantially](http://blog.futtta.be/2010/08/30/the-state-of-wp-youtube-lyte/) when embedding YouTube occasionally and improving page performance dramatically when you've got multiple YouTube video's on one and the same page.
13
 
14
  Just add a YouTube-link for a video or [an entire playlist](http://blog.futtta.be/2011/10/11/wp-youtube-lyte-support-for-playlists-almost-included/) with "httpv" (or "httpa" to [embed YouTube's audio](http://blog.futtta.be/2011/04/19/audio-only-youtube-embedding-with-wp-youtube-lyte-0-7/) only) instead of "http" or add a Lyte widget to your sidebar and WP YouTube Lyte replaces that link with the correct performance-optimized code. When a visitor clicks the play-button, WP YouTube Lyte seamlessly initiates [YouTube's new embedded player](http://apiblog.youtube.com/2010/07/new-way-to-embed-youtube-videos.html). Some examples:
15
 
43
  = Does WP YouTube Lyte protect my visitor's privacy? =
44
  As opposed to some of the [most important](http://blog.futtta.be/2010/12/15/wordpress-com-stats-trojan-horse-for-quantcast-tracking/) [plugins](http://blog.futtta.be/2010/01/22/add-to-any-removed-from-here/) there is no 3rd party tracking code in WP YouTube Lyte, but YouTube off course does see visitor requests coming in (see also the youtube-nocookie.com remark in Bugs/Issues below).
45
 
46
+ = How can I center the player? =
47
+ Centering the player is pretty easy; open up wp-content/plugins/wp-youtube-lyte/lyte/lyte.css and change
48
+ `.lP {background-color:#fff;}`
49
+ into
50
+ `.lP {background-color:#fff;margin:0 auto;}`
51
+
52
  = Can I use WP YouTube Lyte for a custom field? =
53
  As tested and confirmed by [rumultik.ru's Dimitri](http://rumultik.ru) (thanks for that man!), this indeed does work. Just pass the httpv url of such a field to lyte_parse like this:
54
  `if(function_exists('lyte_parse')) { echo lyte_parse($video); }`
68
  * Ask me for a feature you would like to see added
69
  * [Rate my plugin on wordpress.org](http://wordpress.org/extend/plugins/wp-youtube-lyte/), even if you think it stinks ;-)
70
 
71
+ == Screenshots ==
72
+
73
+ 1. This is the administration-page of WP YouTube Lyte.
74
+
75
  == Changelog ==
76
 
77
+ = 1.0.0 =
78
+ * new: also works on (manual) excerpts; just add a httpv link to the "excerpt" field on the post/page admin (based on feedback from [Ruben@tuttingegneri](http://www.tuttingegneri.com))
79
+ * new: if youtube-url contains "start" or "showinfo" parameters, these are used when playing the actual video. This means that you can now jump to a specific time in the YouTube video or stop the title/ author from being displayed (based on feedback from a.o. Miguel and Josh D)
80
+ * update: javascript now initiates either after full page load or after 1 second (whatever comes first), thus avoiding video not showing due to other requests taking too long
81
+ * update: bonus feature stops lockerz.com tracking by addtoany (you'll still want to [hide the "earn pointz" tab though](http://share.lockerz.com/buttons/customize/hide_lockerz_earn_ptz_tab))
82
+ * bugfix: prevent the playing video to be in front of e.g. a dropdown-menu or lightbox (thanks to Matt Whittingham)
83
+ * bugfix: solve overlap between player and text when option was set not to show links (reported by Josh D)
84
+
85
  = 0.9.4 =
86
  * security: WP YouTube Lyte now works entirely in https if your blog is running in https
87
  * performance (js/ page rendering): initiate the javascript a little later (at "load" instead of "DOMContentLoaded") to speed up page load (might need further optimizations)
screenshot-1.png ADDED
Binary file
widget.php CHANGED
@@ -9,6 +9,8 @@ class WYLWidget extends WP_Widget {
9
  function widget($args, $instance) {
10
  extract( $args );
11
  global $wSize, $wyl_version, $wp_lyte_plugin_url;
 
 
12
  $WYLtitle = apply_filters('widget_title', $instance['WYLtitle']);
13
  $WYLtext = apply_filters( 'widget_text', $instance['WYLtext'], $instance );
14
 
@@ -18,16 +20,26 @@ class WYLWidget extends WP_Widget {
18
  $WYLaudio = apply_filters( 'widget_text', $instance['WYLaudio'], $instance );
19
  if ($WYLaudio!=="audio") $WYLaudio="";
20
 
21
- $WYLurl=esc_url(str_replace("httpv://","http://",$instance['WYLurl']));
 
 
 
22
 
23
  if (strpos($WYLurl,'youtu.be')) {
24
  $WYLid=substr(parse_url($WYLurl,PHP_URL_PATH),1,11);
25
  } else {
26
- $WYLqs=substr(strstr($WYLurl,'?'),1);
27
- parse_str($WYLqs,$WYLarr);
28
  $WYLid=$WYLarr['v'];
29
  }
30
 
 
 
 
 
 
 
 
 
 
31
  $WYLid="YLW_".$WYLid;
32
 
33
  $lyteSettings['path']=$wp_lyte_plugin_url."lyte/";
@@ -36,7 +48,7 @@ class WYLWidget extends WP_Widget {
36
  <?php echo $before_widget; ?>
37
  <?php if ( $WYLtitle ) echo $before_title . $WYLtitle . $after_title; ?>
38
  <div class="lyte widget <?php echo $WYLaudio; ?>" id="<?php echo $WYLid; ?>" style="width:<?php echo $wSize[$WYLsize]['w']; ?>px;height:<?php if($WYLaudio==="audio") {echo "25";} else {echo $wSize[$WYLsize]['h'];} ?>px;"><noscript><a href="http://youtu.be/<?php echo $WYLid;?>"><img src="http://img.youtube.com/vi/<?php echo $WYLid; ?>/default.jpg" alt="" /></a></noscript><script type="text/javascript"><!--
39
- (function(){ var d=document;if(d.addEventListener){d.addEventListener('DOMContentLoaded', insert, false)}else{window.onload=insert} function insert(){if(!d.getElementById('lytescr')){lytescr=d.createElement('script');lytescr.async=true;lytescr.id='lytescr';lytescr.src='<?php echo $lyteSettings['path']."lyte-min.js?wylver=".$wyl_version;?>';h=d.getElementsByTagName('script')[0];h.parentNode.insertBefore(lytescr, h)}}; }())
40
  --></script></div>
41
  <div><?php echo $WYLtext ?></div>
42
  <?php echo $after_widget; ?>
9
  function widget($args, $instance) {
10
  extract( $args );
11
  global $wSize, $wyl_version, $wp_lyte_plugin_url;
12
+ $qsa="";
13
+
14
  $WYLtitle = apply_filters('widget_title', $instance['WYLtitle']);
15
  $WYLtext = apply_filters( 'widget_text', $instance['WYLtext'], $instance );
16
 
20
  $WYLaudio = apply_filters( 'widget_text', $instance['WYLaudio'], $instance );
21
  if ($WYLaudio!=="audio") $WYLaudio="";
22
 
23
+ $WYLurl=str_replace("httpv://","http://",$instance['WYLurl']);
24
+
25
+ $WYLqs=substr(strstr($WYLurl,'?'),1);
26
+ parse_str($WYLqs,$WYLarr);
27
 
28
  if (strpos($WYLurl,'youtu.be')) {
29
  $WYLid=substr(parse_url($WYLurl,PHP_URL_PATH),1,11);
30
  } else {
 
 
31
  $WYLid=$WYLarr['v'];
32
  }
33
 
34
+ if (isset($WYLarr['showinfo'])) $qsa="&amp;showinfo=".$WYLarr['showinfo'];
35
+ if (isset($WYLarr['start'])) $qsa.="&amp;start=".$WYLarr['start'];
36
+
37
+ if (!empty($qsa)) {
38
+ $qsa_init="w.lst=w.lst||{};w.lst[\"".$WYLid."\"]=\"".$qsa."\"";
39
+ } else {
40
+ $qsa_init="";
41
+ }
42
+
43
  $WYLid="YLW_".$WYLid;
44
 
45
  $lyteSettings['path']=$wp_lyte_plugin_url."lyte/";
48
  <?php echo $before_widget; ?>
49
  <?php if ( $WYLtitle ) echo $before_title . $WYLtitle . $after_title; ?>
50
  <div class="lyte widget <?php echo $WYLaudio; ?>" id="<?php echo $WYLid; ?>" style="width:<?php echo $wSize[$WYLsize]['w']; ?>px;height:<?php if($WYLaudio==="audio") {echo "25";} else {echo $wSize[$WYLsize]['h'];} ?>px;"><noscript><a href="http://youtu.be/<?php echo $WYLid;?>"><img src="http://img.youtube.com/vi/<?php echo $WYLid; ?>/default.jpg" alt="" /></a></noscript><script type="text/javascript"><!--
51
+ (function(){ var w=window;d=document;if(d.addEventListener){d.addEventListener('DOMContentLoaded', insert, false)}else{w.onload=insert} function insert(){if(!d.getElementById('lytescr')){lytescr=d.createElement('script');lytescr.async=true;lytescr.id='lytescr';lytescr.src='<?php echo $lyteSettings['path']."lyte-min.js?wylver=".$wyl_version;?>';h=d.getElementsByTagName('script')[0];h.parentNode.insertBefore(lytescr, h)}<?php echo $qsa_init; ?>}; }())
52
  --></script></div>
53
  <div><?php echo $WYLtext ?></div>
54
  <?php echo $after_widget; ?>
wp-youtube-lyte.php CHANGED
@@ -1,16 +1,16 @@
1
  <?php
2
  /*
3
  Plugin Name: WP YouTube Lyte
4
- Plugin URI: http://blog.futtta.be/tag/lyte
5
  Description: Lite and accessible YouTube audio and video embedding.
6
  Author: Frank Goossens (futtta)
7
- Version: 0.9.4
8
  Author URI: http://blog.futtta.be/
9
  Text Domain: wp-youtube-lyte
10
  Domain Path: /languages
11
  */
12
 
13
- $wyl_version="0.9.4";
14
 
15
  $plugin_dir = basename(dirname(__FILE__)).'/languages';
16
  load_plugin_textdomain( 'wp-youtube-lyte', null, $plugin_dir );
@@ -62,6 +62,12 @@ function lyte_parse($the_content) {
62
 
63
  foreach($matches as $match) {
64
  preg_match("/stepSize\=([\+\-0-9]{2})/",$match[12],$sMatch);
 
 
 
 
 
 
65
  if (!empty($sMatch)) {
66
  $newSize=(int) $sMatch[1];
67
  $newPos=(int) $lyteSettings['selSize']+$newSize;
@@ -85,26 +91,29 @@ function lyte_parse($the_content) {
85
  $divHeight=34;
86
  }
87
 
 
 
 
88
  if ($match[11]!="") {
89
  $plClass=" playlist";
90
  $vid=$match[11];
91
  switch ($lyteSettings['links']) {
92
  case "0":
93
- $noscript_post="<br />".__("Watch this playlist on YouTube","wp-youtube-lyte")."&lyte;.";
94
- $noscript="<noscript><a href=\"".$scheme."://youtube.com/playlist?list=PL".$vid."\">".$noscript_post."</a>.</noscript>";
95
  $lytelinks_txt="";
96
  break;
97
  default:
98
- $noscript="";
99
- $lytelinks_txt="<div class=\"lL\">".__("Watch this playlist","wp-youtube-lyte")." <a href=\"".$scheme."://www.youtube.com/playlist?list=PL".$vid."\">".__("on YouTube","wp-youtube-lyte")."</a>.</div>";
100
  }
101
  } else if ($match[9]!="") {
102
  $plClass="";
103
  $vid=$match[9];
104
  switch ($lyteSettings['links']) {
105
  case "0":
106
- $noscript_post="<br />".__("Watch this video on YouTube","wp-youtube-lyte").".";
107
- $lytelinks_txt="";
108
  break;
109
  case "2":
110
  $noscript_post="";
@@ -115,10 +124,16 @@ function lyte_parse($the_content) {
115
  $lytelinks_txt="<div class=\"lL\">".__("Watch this video","wp-youtube-lyte")." <a href=\"".$scheme."://youtu.be/".$vid."\">".__("on YouTube","wp-youtube-lyte")."</a>.</div>";
116
  }
117
 
118
- $noscript="<noscript><a href=\"".$scheme."://youtu.be/".$vid."\"><img src=\"".$scheme."//img.youtube.com/vi/".$vid."/0.jpg\" alt=\"\" width=\"".$lyteSettings[2]."\" height=\"".$divHeight."\" />".$noscript_post."</a></noscript>";
119
  }
120
 
121
- $lytetemplate = "<div class=\"lyte".$audioClass.$hidefClass.$plClass."\" id=\"WYL_".$vid."\" style=\"width:".$lyteSettings[2]."px;height:".$divHeight."px;\">".$noscript."<script type=\"text/javascript\"><!-- \n (function(){var d=document;var w=window;if(w.addEventListener){w.addEventListener('load', insert, false)}else{w.onload=insert} function insert(){if(!d.getElementById('lytescr')){lytescr=d.createElement('script');lytescr.async=true;lytescr.id='lytescr';lytescr.src='".$lyteSettings['path']."lyte-min.js?wylver=".$lyteSettings['version']."';h=d.getElementsByTagName('script')[0];h.parentNode.insertBefore(lytescr, h)}};}()) \n --></script></div>".$lytelinks_txt;
 
 
 
 
 
 
122
  $the_content = preg_replace("/(<p>)?http(v|a):\/\/([a-zA-Z0-9\-\_]+\.|)(youtube|youtu)(\.com|\.be)\/(((watch(\?v\=|\/v\/)|)([a-zA-Z0-9\-\_]{11}))|(playlist\?list\=PL([a-zA-Z0-9\-\_]{16})))([^\s<]*)(<\/p>)?/", $lytetemplate, $the_content, 1);
123
  }
124
  }
@@ -129,6 +144,7 @@ if ( is_admin() ) {
129
  require_once(dirname(__FILE__).'/options.php');
130
  } else {
131
  add_filter('the_content', 'lyte_parse', 4);
 
132
  }
133
 
134
  /* donottrack */
@@ -138,17 +154,22 @@ if ($_SERVER['HTTPS']) {
138
  $donottrack_js = str_replace( "http:","https:",$donottrack_js );
139
  }
140
 
141
- function init_lyte_donottrack() {
142
  global $donottrack_js;
143
  wp_enqueue_script( 'donottrack',$donottrack_js );
144
  }
145
 
146
  function lyte_donottrack_config() {
147
- echo "<script type=\"text/javascript\">var dnt_config={ifdnt:\"\",mode:\"blacklist\",black:[\"media6degrees.com\",\"quantserve.com\"],white:[]};</script>\n";
 
 
 
 
148
  }
149
 
150
  if (get_option('donottrack')==="1") {
151
  add_action('wp_print_scripts', 'lyte_donottrack_config');
152
- add_action('init', 'init_lyte_donottrack');
 
153
  }
154
  ?>
1
  <?php
2
  /*
3
  Plugin Name: WP YouTube Lyte
4
+ Plugin URI: http://blog.futtta.be/wp-youtube-lyte/
5
  Description: Lite and accessible YouTube audio and video embedding.
6
  Author: Frank Goossens (futtta)
7
+ Version: 1.0.0
8
  Author URI: http://blog.futtta.be/
9
  Text Domain: wp-youtube-lyte
10
  Domain Path: /languages
11
  */
12
 
13
+ $wyl_version="1.0.0";
14
 
15
  $plugin_dir = basename(dirname(__FILE__)).'/languages';
16
  load_plugin_textdomain( 'wp-youtube-lyte', null, $plugin_dir );
62
 
63
  foreach($matches as $match) {
64
  preg_match("/stepSize\=([\+\-0-9]{2})/",$match[12],$sMatch);
65
+ preg_match("/showinfo\=([0-1]{1})/",$match[12],$showinfo);
66
+ preg_match("/start\=([0-9]*)/",$match[12],$start);
67
+
68
+ if ($showinfo[0]) $qsa="&amp;".$showinfo[0];
69
+ if ($start[0]) $qsa.="&amp;".$start[0];
70
+
71
  if (!empty($sMatch)) {
72
  $newSize=(int) $sMatch[1];
73
  $newPos=(int) $lyteSettings['selSize']+$newSize;
91
  $divHeight=34;
92
  }
93
 
94
+ $NSimgHeight=$divHeight-20;
95
+ $NSbanner="Embedded with WP YouTube Lyte.";
96
+
97
  if ($match[11]!="") {
98
  $plClass=" playlist";
99
  $vid=$match[11];
100
  switch ($lyteSettings['links']) {
101
  case "0":
102
+ $noscript_post="<br />".__("Watch this playlist on YouTube","wp-youtube-lyte");
103
+ $noscript="<noscript><a href=\"".$scheme."://youtube.com/playlist?list=PL".$vid."\">".$noscript_post."</a> ".$NSbanner."</noscript>";
104
  $lytelinks_txt="";
105
  break;
106
  default:
107
+ $noscript="<noscript>".$NSbanner."</noscript>";
108
+ $lytelinks_txt="<div class=\"lL\">".__("Watch this playlist","wp-youtube-lyte")." <a href=\"".$scheme."://www.youtube.com/playlist?list=PL".$vid."\">".__("on YouTube","wp-youtube-lyte")."</a></div>";
109
  }
110
  } else if ($match[9]!="") {
111
  $plClass="";
112
  $vid=$match[9];
113
  switch ($lyteSettings['links']) {
114
  case "0":
115
+ $noscript_post="<br />".__("Watch this video on YouTube","wp-youtube-lyte");
116
+ $lytelinks_txt="<div class=\"lL\"></div>";
117
  break;
118
  case "2":
119
  $noscript_post="";
124
  $lytelinks_txt="<div class=\"lL\">".__("Watch this video","wp-youtube-lyte")." <a href=\"".$scheme."://youtu.be/".$vid."\">".__("on YouTube","wp-youtube-lyte")."</a>.</div>";
125
  }
126
 
127
+ $noscript="<noscript><a href=\"".$scheme."://youtu.be/".$vid."\"><img src=\"".$scheme."://img.youtube.com/vi/".$vid."/0.jpg\" alt=\"\" width=\"".$lyteSettings[2]."\" height=\"".$NSimgHeight."\" />".$noscript_post."</a> ".$NSbanner."</noscript>";
128
  }
129
 
130
+ if (!empty($qsa)) {
131
+ $qsa_init="w.lst=w.lst||{};w.lst[\"".$vid."\"]=\"".$qsa."\"";
132
+ } else {
133
+ $qsa_init="";
134
+ }
135
+
136
+ $lytetemplate = "<div class=\"lyte".$audioClass.$hidefClass.$plClass."\" id=\"WYL_".$vid."\" style=\"width:".$lyteSettings[2]."px;height:".$divHeight."px;\">".$noscript."<script type=\"text/javascript\"><!-- \n (function(){var d=document;var w=window;if(w.addEventListener){w.addEventListener('load', insert, false)}else{w.onload=insert};setTimeout(insert, 1000);function insert(){if(!d.getElementById('lytescr')){lytescr=d.createElement('script');lytescr.async=true;lytescr.id='lytescr';lytescr.src='".$lyteSettings['path']."lyte-min.js?wylver=".$lyteSettings['version']."';h=d.getElementsByTagName('script')[0];h.parentNode.insertBefore(lytescr, h)}};".$qsa_init."}()) \n --></script></div>".$lytelinks_txt;
137
  $the_content = preg_replace("/(<p>)?http(v|a):\/\/([a-zA-Z0-9\-\_]+\.|)(youtube|youtu)(\.com|\.be)\/(((watch(\?v\=|\/v\/)|)([a-zA-Z0-9\-\_]{11}))|(playlist\?list\=PL([a-zA-Z0-9\-\_]{16})))([^\s<]*)(<\/p>)?/", $lytetemplate, $the_content, 1);
138
  }
139
  }
144
  require_once(dirname(__FILE__).'/options.php');
145
  } else {
146
  add_filter('the_content', 'lyte_parse', 4);
147
+ add_filter('the_excerpt', 'lyte_parse', 4);
148
  }
149
 
150
  /* donottrack */
154
  $donottrack_js = str_replace( "http:","https:",$donottrack_js );
155
  }
156
 
157
+ function lyte_donottrack_init() {
158
  global $donottrack_js;
159
  wp_enqueue_script( 'donottrack',$donottrack_js );
160
  }
161
 
162
  function lyte_donottrack_config() {
163
+ echo "<script type=\"text/javascript\">var dnt_config={ifdnt:\"\",mode:\"blacklist\",black:[\"media6degrees.com\",\"quantserve.com\",\"lockerz.com\"],white:[]};</script>\n";
164
+ }
165
+
166
+ function lyte_donottrack_footer() {
167
+ echo "<script type=\"text/javascript\">aop_around(document.body, 'appendChild'); aop_around(document.body, 'insertBefore');</script>";
168
  }
169
 
170
  if (get_option('donottrack')==="1") {
171
  add_action('wp_print_scripts', 'lyte_donottrack_config');
172
+ add_action('init', 'lyte_donottrack_init');
173
+ add_action('wp_footer', 'lyte_donottrack_footer');
174
  }
175
  ?>