Version Description
- LYTE embeds are now fully responsive
- automatic inclusion of scheme.org microdata (VideoObject)
- even better performance (less requests; was 5, now 3)
- updated to current YouTube look & feel
- less JavaScript, more CSS
- bugfix: all lyte-output is now removed from excerpts
Download this release
Release Info
Developer | futtta |
Plugin | WP YouTube Lyte |
Version | 1.2.0 |
Comparing to | |
See all releases |
Code changes from version 1.1.9 to 1.2.0
- lyte/controls-1280.png +0 -0
- lyte/controls-150.png +0 -0
- lyte/controls-160.png +0 -0
- lyte/controls-180.png +0 -0
- lyte/controls-200.png +0 -0
- lyte/controls-250.png +0 -0
- lyte/controls-400.png +0 -0
- lyte/controls-420.png +0 -0
- lyte/controls-480.png +0 -0
- lyte/controls-560.png +0 -0
- lyte/controls-640.png +0 -0
- lyte/controls-853.png +0 -0
- lyte/controls-960.png +0 -0
- lyte/lyte-min.js +1 -1
- lyte/lyte.js +34 -91
- lyte/lytesprite.png +0 -0
- lyte/play.png +0 -0
- options.php +32 -27
- player_sizes.inc.php +5 -2
- readme.txt +26 -6
- widget.php +30 -24
- wp-youtube-lyte.php +189 -43
lyte/controls-1280.png
DELETED
Binary file
|
lyte/controls-150.png
DELETED
Binary file
|
lyte/controls-160.png
DELETED
Binary file
|
lyte/controls-180.png
DELETED
Binary file
|
lyte/controls-200.png
DELETED
Binary file
|
lyte/controls-250.png
DELETED
Binary file
|
lyte/controls-400.png
DELETED
Binary file
|
lyte/controls-420.png
DELETED
Binary file
|
lyte/controls-480.png
DELETED
Binary file
|
lyte/controls-560.png
DELETED
Binary file
|
lyte/controls-640.png
DELETED
Binary file
|
lyte/controls-853.png
DELETED
Binary file
|
lyte/controls-960.png
DELETED
Binary file
|
lyte/lyte-min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(function(
|
1 |
+
(function(e){var t=document;var n="http";if(bU.indexOf("https")!=-1){n+="s"}e.te=function(){if(!n){var n=1;var r=navigator.userAgent.match(/(iphone|ipad|ipod|android)/i);lts=e.getElementsByClassName("lyMe","div");for(var i=0,s=lts.length;i<s;i+=1){p=lts[i];vid=p.id.substring(4);if(r===null){cN=p.className.replace(/lyMe/,"lyte")+" lP";p.className=cN;sprite=bU+"lytesprite.png";e.addCss(".lyte .ctrl, .lyte .Rctrl, .lyte .Lctrl, .lyte .play { background-image: url("+sprite+"); }");if(cN.indexOf("audio")===-1){bgId="lyte_"+vid;thumb=t.getElementById(bgId).getAttribute("data-src");bgCss="#"+bgId+" { background-image: url("+thumb+"); }";e.addCss(bgCss)}p.onclick=e.play}else{e.play(p.id)}}}var n=""};e.getQ=function(e){qsa="";if(rqs=e.className.match(/qsa_(.*)\s/,"$1"))qsa=rqs[1].replace(/\\([\&\=\?])/g,"$1");return qsa};e.play=function(r){if(typeof r==="string"){tH=t.getElementById(r);aP=0}else{tH=this;tH.onclick="";aP=1}vid=tH.id.substring(4);hidef=0;if(tH.className.indexOf("hidef")!==-1){hidef="1&vq=hd720"}if(tH.className.indexOf("playlist")===-1){eU=n+"://www.youtube.com/embed/"+vid+"?"}else{eU=n+"://www.youtube.com/embed/videoseries?list="+vid+"&"}qsa=e.getQ(tH);if(tH.className.indexOf("audio")!==-1){qsa+="&autohide=0";aHgh="438";aSt="position:relative;top:-400px;"}else{aHgh=tH.clientHeight;aSt=""}tH.innerHTML='<iframe id="iF_'+vid+'" width="'+tH.clientWidth+'px" height="'+aHgh+'px" src="'+eU+"autoplay="+aP+"&wmode=opaque&rel=0&egm=0&iv_load_policy=3&hd="+hidef+qsa+'" frameborder="0" style="'+aSt+'" allowfullscreen></iframe>';if(typeof tH.firstChild.getAttribute("kabl")=="string")tH.innerHTML="Please check Karma Blocker's config."};e.getElementsByClassName=function(e,n,r){if(t.getElementsByClassName){getElementsByClassName=function(e,n,r){r=r||t;var i=r.getElementsByClassName(e),s=n?new RegExp("\\b"+n+"\\b","i"):null,o=[],u;for(var a=0,f=i.length;a<f;a+=1){u=i[a];if(!s||s.test(u.nodeName)){o.push(u)}}return o}}else if(t.evaluate){getElementsByClassName=function(e,n,r){n=n||"*";r=r||t;var i=e.split(" "),s="",o="http://www.w3.org/1999/xhtml",u=t.documentElement.namespaceURI===o?o:null,a=[],f,l;for(var c=0,h=i.length;c<h;c+=1){s+="[contains(concat(' ', @class, ' '), ' "+i[c]+" ')]"}try{f=t.evaluate(".//"+n+s,r,u,0,null)}catch(p){f=t.evaluate(".//"+n+s,r,null,0,null)}while(l=f.iterateNext()){a.push(l)}return a}}else{getElementsByClassName=function(e,n,r){n=n||"*";r=r||t;var i=e.split(" "),s=[],o=n==="*"&&r.all?r.all:r.getElementsByTagName(n),u,a=[],f;for(var l=0,c=i.length;l<c;l+=1){s.push(new RegExp("(^|\\s)"+i[l]+"(\\s|$)"))}for(var h=0,p=o.length;h<p;h+=1){u=o[h];f=false;for(var v=0,m=s.length;v<m;v+=1){f=s[v].test(u.className);if(!f){break}}if(f){a.push(u)}}return a}}return getElementsByClassName(e,n,r)};e.addCss=function(e){var n=t.createElement("style");n.type="text/css";if(n.styleSheet){n.styleSheet.cssText=e}else{n.appendChild(document.createTextNode(e))}t.getElementsByTagName("head")[0].appendChild(n)}})(window.ly=window.ly||{});(function(){var e=window;var t=document;if(e.addEventListener){e.addEventListener("load",ly.te,false);t.addEventListener("DomContentLoaded",function(){setTimeout("ly.te()",750)},false)}else{e.onload=ly.te;setTimeout("ly.te()",1e3)}})()
|
lyte/lyte.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
(function( ly ) {
|
2 |
-
d = document;
|
3 |
|
4 |
var sch="http";
|
5 |
if (bU.indexOf('https')!=-1) {sch+="s"}
|
@@ -7,48 +7,24 @@ if (bU.indexOf('https')!=-1) {sch+="s"}
|
|
7 |
ly.te = function() {
|
8 |
if (!rn) {
|
9 |
var rn=1;
|
10 |
-
var
|
11 |
-
lts = getElementsByClassName("lyMe", "div");
|
|
|
12 |
for (var i = 0, lln = lts.length; i < lln; i += 1) {
|
13 |
p = lts[i];
|
14 |
vid = p.id.substring(4);
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
22 |
p.onclick = ly.play;
|
23 |
-
pW = p.style.width.match(/\d+/g)[0];
|
24 |
-
pH = p.style.height.match(/\d+/g)[0];
|
25 |
-
|
26 |
-
bgA="-60px";
|
27 |
-
if ((cN.indexOf('widget') !== -1)||(pW/pH<1.7)) bgA="-10px";
|
28 |
-
|
29 |
-
qsa=getQ(p);
|
30 |
-
|
31 |
-
cImg="<img src=\"" + bU + "controls-" + pW + ".png\" height=\"40px\" width=\""+pW+"px\" class=\"ctrl\" alt=\"\"/>";
|
32 |
-
pImg="<img src=\"" + bU + "play.png\" width=\"83px\" height=\"55px\" alt=\"Click to play\" style=\"margin-top:" + ((pH / 2) - 30) + "px;opacity:0.7;\" onmouseover=\"this.style.opacity=1;\" onmouseout=\"this.style.opacity=0.8;\"/>";
|
33 |
-
ytA="://gdata.youtube.com/feeds/api/";
|
34 |
-
|
35 |
-
if (cN.indexOf('audio') !== -1) {
|
36 |
-
setST(pl, 'height:' + pH + 'px;width:' + pW + 'px;');
|
37 |
-
pl.innerHTML = cImg;
|
38 |
-
} else if (cN.indexOf('playlist') !== -1) {
|
39 |
-
setST(pl, 'height:' + pH + 'px;width:' + pW + 'px;');
|
40 |
-
pl.innerHTML = pImg+cImg;
|
41 |
-
joU = sch+ytA+"playlists/"+ vid +"?v=2&alt=json-in-script&callback=ly.prsPL&fields=id,title,entry";
|
42 |
-
loadSC(joU);
|
43 |
-
} else {
|
44 |
-
setST(pl, "height:" + pH + "px;width:" + pW + "px;background:url('" + sch + "://i.ytimg.com/vi/" + vid + "/0.jpg') no-repeat scroll center " + bgA + " rgb(0, 0, 0);background-size:cover;");
|
45 |
-
pl.innerHTML = pImg+cImg;
|
46 |
-
if ((cN.indexOf('widget') === -1) && (qsa.indexOf('showinfo=0') === -1)) {
|
47 |
-
joU = sch+ytA+"videos/" + vid + "?fields=id,title&alt=json-in-script&callback=ly.prsV";
|
48 |
-
loadSC(joU)
|
49 |
-
}
|
50 |
-
}
|
51 |
-
p.appendChild(pl);
|
52 |
} else {
|
53 |
ly.play(p.id);
|
54 |
}
|
@@ -57,7 +33,7 @@ ly.te = function() {
|
|
57 |
var rn="";
|
58 |
}
|
59 |
|
60 |
-
function
|
61 |
qsa="";
|
62 |
if (rqs=nD.className.match(/qsa_(.*)\s/,"$1")) qsa=rqs[1].replace(/\\([\&\=\?])/g, "$1");
|
63 |
return qsa;
|
@@ -72,10 +48,11 @@ ly.play = function(id) {
|
|
72 |
tH.onclick="";
|
73 |
aP=1;
|
74 |
}
|
|
|
75 |
vid=tH.id.substring(4);
|
76 |
|
77 |
hidef=0;
|
78 |
-
if (tH.className.indexOf("hidef") !== -1) { hidef=1; }
|
79 |
|
80 |
if (tH.className.indexOf("playlist") === -1) {
|
81 |
eU=sch+"://www.youtube.com/embed/" + vid + "?"
|
@@ -83,61 +60,16 @@ ly.play = function(id) {
|
|
83 |
eU=sch+"://www.youtube.com/embed/videoseries?list=" + vid + "&"
|
84 |
}
|
85 |
|
86 |
-
qsa=getQ(tH);
|
87 |
-
|
88 |
-
if (tH.className.indexOf("audio") !== -1) { qsa+="&autohide=0";aHgh="438";aSt="position:relative;top:-400px;" } else { aHgh=tH.clientHeight;aSt=""; }
|
89 |
|
|
|
|
|
90 |
tH.innerHTML="<iframe id=\"iF_" + vid + "\" width=\"" + tH.clientWidth + "px\" height=\"" + aHgh + "px\" src=\""+eU+"autoplay="+aP+"&wmode=opaque&rel=0&egm=0&iv_load_policy=3&hd="+hidef+qsa+"\" frameborder=\"0\" style=\"" + aSt + "\" allowfullscreen></iframe>"
|
91 |
|
92 |
if(typeof tH.firstChild.getAttribute('kabl')=="string") tH.innerHTML="Please check Karma Blocker's config.";
|
93 |
}
|
94 |
|
95 |
-
ly.
|
96 |
-
tI = r.entry.title.$t;
|
97 |
-
idu = r.entry.id.$t;
|
98 |
-
id = "lyte_" + idu.substring(idu.length - 11);
|
99 |
-
drawT(id,tI);
|
100 |
-
}
|
101 |
-
|
102 |
-
ly.prsPL = function(r) {
|
103 |
-
thumb=r.feed.entry[0].media$group.media$thumbnail[1].url
|
104 |
-
idu=r.feed.id.$t
|
105 |
-
id="lyte_"+idu.match(/PL[a-zA-Z0-9\-\_]*/)[0]
|
106 |
-
title="Playlist: "+r.feed.title.$t
|
107 |
-
pl=d.getElementById(id)
|
108 |
-
pH=pl.style.height;
|
109 |
-
pW=pl.style.width;
|
110 |
-
|
111 |
-
if ((sch=="https")&&(thumb.indexOf('https'==-1))) {thumb=thumb.replace("http://","https://");}
|
112 |
-
|
113 |
-
setST(pl, "height:" + pH + ";width:" + pW + ";background:url('" + thumb + "') no-repeat scroll center -50px rgb(0, 0, 0); background-size:cover;")
|
114 |
-
drawT(id,title)
|
115 |
-
}
|
116 |
-
|
117 |
-
function drawT(id,tI) {
|
118 |
-
p = d.getElementById(id);
|
119 |
-
c = d.createElement('div');
|
120 |
-
c.className = "tC";
|
121 |
-
t = d.createElement('div');
|
122 |
-
t.className = "tT";
|
123 |
-
c.appendChild(t);
|
124 |
-
t.innerHTML = tI;
|
125 |
-
p.appendChild(c);
|
126 |
-
}
|
127 |
-
|
128 |
-
function setST(e, s) {
|
129 |
-
if (typeof e.setAttribute === "function") e.setAttribute('style', s);
|
130 |
-
else if (typeof e.style.setAttribute === "object") e.style.setAttribute('cssText', s)
|
131 |
-
}
|
132 |
-
|
133 |
-
function loadSC(url) {
|
134 |
-
scr = d.createElement('script');
|
135 |
-
scr.src = url;
|
136 |
-
scr.type = 'text/javascript';
|
137 |
-
d.getElementsByTagName('head')[0].appendChild(scr)
|
138 |
-
}
|
139 |
-
|
140 |
-
function getElementsByClassName (className, tag, elm) {
|
141 |
if (d.getElementsByClassName) {
|
142 |
getElementsByClassName = function (className, tag, elm) {
|
143 |
elm = elm || d;
|
@@ -207,7 +139,18 @@ function getElementsByClassName (className, tag, elm) {
|
|
207 |
return getElementsByClassName(className, tag, elm)
|
208 |
};
|
209 |
|
210 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
|
212 |
(function(){
|
213 |
var w = window;
|
1 |
(function( ly ) {
|
2 |
+
var d = document;
|
3 |
|
4 |
var sch="http";
|
5 |
if (bU.indexOf('https')!=-1) {sch+="s"}
|
7 |
ly.te = function() {
|
8 |
if (!rn) {
|
9 |
var rn=1;
|
10 |
+
var mOs=navigator.userAgent.match(/(iphone|ipad|ipod|android)/i);
|
11 |
+
lts = ly.getElementsByClassName("lyMe", "div");
|
12 |
+
|
13 |
for (var i = 0, lln = lts.length; i < lln; i += 1) {
|
14 |
p = lts[i];
|
15 |
vid = p.id.substring(4);
|
16 |
+
if (mOs === null) {
|
17 |
+
cN = p.className.replace(/lyMe/, "lyte")+ " lP";
|
18 |
+
p.className = cN;
|
19 |
+
sprite=(bU+"lytesprite.png");
|
20 |
+
ly.addCss(".lyte .ctrl, .lyte .Rctrl, .lyte .Lctrl, .lyte .play { background-image: url("+sprite+"); }");
|
21 |
+
if (cN.indexOf('audio') === -1) {
|
22 |
+
bgId="lyte_"+vid;
|
23 |
+
thumb=d.getElementById(bgId).getAttribute("data-src");
|
24 |
+
bgCss="#"+bgId+" { background-image: url("+thumb+"); }";
|
25 |
+
ly.addCss(bgCss);
|
26 |
+
}
|
27 |
p.onclick = ly.play;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
} else {
|
29 |
ly.play(p.id);
|
30 |
}
|
33 |
var rn="";
|
34 |
}
|
35 |
|
36 |
+
ly.getQ = function(nD) {
|
37 |
qsa="";
|
38 |
if (rqs=nD.className.match(/qsa_(.*)\s/,"$1")) qsa=rqs[1].replace(/\\([\&\=\?])/g, "$1");
|
39 |
return qsa;
|
48 |
tH.onclick="";
|
49 |
aP=1;
|
50 |
}
|
51 |
+
|
52 |
vid=tH.id.substring(4);
|
53 |
|
54 |
hidef=0;
|
55 |
+
if (tH.className.indexOf("hidef") !== -1) { hidef="1&vq=hd720" }
|
56 |
|
57 |
if (tH.className.indexOf("playlist") === -1) {
|
58 |
eU=sch+"://www.youtube.com/embed/" + vid + "?"
|
60 |
eU=sch+"://www.youtube.com/embed/videoseries?list=" + vid + "&"
|
61 |
}
|
62 |
|
63 |
+
qsa=ly.getQ(tH);
|
|
|
|
|
64 |
|
65 |
+
if (tH.className.indexOf("audio") !== -1) { qsa+="&autohide=0";aHgh="438";aSt="position:relative;top:-400px;" } else { aHgh=tH.clientHeight;aSt=""; }
|
66 |
+
|
67 |
tH.innerHTML="<iframe id=\"iF_" + vid + "\" width=\"" + tH.clientWidth + "px\" height=\"" + aHgh + "px\" src=\""+eU+"autoplay="+aP+"&wmode=opaque&rel=0&egm=0&iv_load_policy=3&hd="+hidef+qsa+"\" frameborder=\"0\" style=\"" + aSt + "\" allowfullscreen></iframe>"
|
68 |
|
69 |
if(typeof tH.firstChild.getAttribute('kabl')=="string") tH.innerHTML="Please check Karma Blocker's config.";
|
70 |
}
|
71 |
|
72 |
+
ly.getElementsByClassName = function(className, tag, elm) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
if (d.getElementsByClassName) {
|
74 |
getElementsByClassName = function (className, tag, elm) {
|
75 |
elm = elm || d;
|
139 |
return getElementsByClassName(className, tag, elm)
|
140 |
};
|
141 |
|
142 |
+
ly.addCss = function(cssCode) {
|
143 |
+
var stEl = d.createElement("style");
|
144 |
+
stEl.type = "text/css";
|
145 |
+
if (stEl.styleSheet) {
|
146 |
+
stEl.styleSheet.cssText = cssCode;
|
147 |
+
} else {
|
148 |
+
stEl.appendChild(document.createTextNode(cssCode));
|
149 |
+
}
|
150 |
+
d.getElementsByTagName("head")[0].appendChild(stEl);
|
151 |
+
}
|
152 |
+
}
|
153 |
+
( window.ly = window.ly || {} ));
|
154 |
|
155 |
(function(){
|
156 |
var w = window;
|
lyte/lytesprite.png
ADDED
Binary file
|
lyte/play.png
DELETED
Binary file
|
options.php
CHANGED
@@ -12,16 +12,17 @@ function lyte_create_menu() {
|
|
12 |
}
|
13 |
|
14 |
function register_lyte_settings() {
|
15 |
-
register_setting( 'lyte-settings-group', '
|
16 |
-
register_setting( 'lyte-settings-group', '
|
17 |
-
register_setting( 'lyte-settings-group', '
|
18 |
-
register_setting( 'lyte-settings-group', '
|
19 |
-
register_setting( 'lyte-settings-group', '
|
|
|
20 |
}
|
21 |
|
22 |
function lyte_admin_scripts() {
|
23 |
-
wp_enqueue_script('jqzrssfeed', plugins_url('/external/jquery.zrssfeed.min.js', __FILE__), array(jquery),null,true);
|
24 |
-
wp_enqueue_script('jqcookie', plugins_url('/external/jquery.cookie.min.js', __FILE__), array(jquery),null,true);
|
25 |
}
|
26 |
|
27 |
function lyte_admin_styles() {
|
@@ -32,12 +33,13 @@ function lyte_admin_notice(){
|
|
32 |
echo '<div class="updated"><p>Hello WP YouTube Lyte user!<br />Just to let you know that <strong>the bonus feature, DoNotTrack, was removed</strong> from WP YouTube Lyte. If you would like to keep blocking third party tracking on your blog, you might want to <strong>install <a href="http://wordpress.org/extend/plugins/wp-donottrack/" title="WP DoNotTrack">WP DoNotTrack</a></strong>, which is a more powerful and flexible solution.</p><p>Have a great day!<br /><a href="http://blog.futtta.be/">frank</a>.</div>';
|
33 |
}
|
34 |
|
35 |
-
if (get_option('
|
36 |
add_action('admin_notices', 'lyte_admin_notice');
|
37 |
-
update_option('
|
38 |
}
|
39 |
|
40 |
function lyte_settings_page() {
|
|
|
41 |
?>
|
42 |
<div class="wrap">
|
43 |
<h2><?php _e("WP YouTube Lyte Settings","wp-youtube-lyte") ?></h2>
|
@@ -48,20 +50,20 @@ function lyte_settings_page() {
|
|
48 |
<form method="post" action="options.php">
|
49 |
<?php settings_fields( 'lyte-settings-group' ); ?>
|
50 |
<table class="form-table">
|
51 |
-
<input type="hidden" name="
|
52 |
|
53 |
<tr valign="top">
|
54 |
<th scope="row">Player size:</th>
|
55 |
<td>
|
56 |
<fieldset><legend class="screen-reader-text"><span><?php _e("Player size","wp-youtube-lyte") ?></span></legend>
|
57 |
-
<?php
|
58 |
-
if (is_bool(get_option('
|
59 |
foreach (array("169","43") as $f) {
|
60 |
foreach ($pSizeOrder[$f] as $i) {
|
61 |
$pS=$pSize[$i];
|
62 |
if ($pS[a]===true) {
|
63 |
?>
|
64 |
-
<label title="<?php echo $pS[w]."X".$pS[h]; ?>"><input type="radio" name="
|
65 |
<?php
|
66 |
}
|
67 |
}
|
@@ -76,9 +78,9 @@ function lyte_settings_page() {
|
|
76 |
<td>
|
77 |
<fieldset>
|
78 |
<legend class="screen-reader-text"><span><?php _e("Show links?","wp-youtube-lyte") ?></span></legend>
|
79 |
-
<label title="Show YouTube-link"><input type="radio" name="
|
80 |
-
<label title="Show YouTube and Ease YouTube link"><input type="radio" name="
|
81 |
-
<label title="Don't include links."><input type="radio" name="
|
82 |
</fieldset>
|
83 |
</td>
|
84 |
</tr>
|
@@ -87,27 +89,30 @@ function lyte_settings_page() {
|
|
87 |
<td>
|
88 |
<fieldset>
|
89 |
<legend class="screen-reader-text"><span>Left, center or right?</span></legend>
|
90 |
-
<label title="Left"><input type="radio" name="
|
91 |
-
<label title="Center"><input type="radio" name="
|
92 |
</fieldset>
|
93 |
</td>
|
94 |
</tr>
|
95 |
<tr valign="top">
|
96 |
-
<th scope="row"><?php _e("
|
97 |
<td>
|
98 |
<fieldset>
|
99 |
<legend class="screen-reader-text"><span>HD or not?</span></legend>
|
100 |
-
<label title="Enable HD?"><input type="radio" name="
|
101 |
-
<label title="Don't enable HD playback"><input type="radio" name="
|
102 |
</fieldset>
|
103 |
</td>
|
104 |
</tr>
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
|
|
|
|
|
|
111 |
</tr>
|
112 |
</table>
|
113 |
|
12 |
}
|
13 |
|
14 |
function register_lyte_settings() {
|
15 |
+
register_setting( 'lyte-settings-group', 'lyte_show_links' );
|
16 |
+
register_setting( 'lyte-settings-group', 'lyte_size' );
|
17 |
+
register_setting( 'lyte-settings-group', 'lyte_hidef' );
|
18 |
+
register_setting( 'lyte-settings-group', 'lyte_position' );
|
19 |
+
register_setting( 'lyte-settings-group', 'lyte_notification' );
|
20 |
+
register_setting( 'lyte-settings-group', 'lyte_microdata' );
|
21 |
}
|
22 |
|
23 |
function lyte_admin_scripts() {
|
24 |
+
wp_enqueue_script('jqzrssfeed', plugins_url('/external/jquery.zrssfeed.min.js', __FILE__), array('jquery'),null,true);
|
25 |
+
wp_enqueue_script('jqcookie', plugins_url('/external/jquery.cookie.min.js', __FILE__), array('jquery'),null,true);
|
26 |
}
|
27 |
|
28 |
function lyte_admin_styles() {
|
33 |
echo '<div class="updated"><p>Hello WP YouTube Lyte user!<br />Just to let you know that <strong>the bonus feature, DoNotTrack, was removed</strong> from WP YouTube Lyte. If you would like to keep blocking third party tracking on your blog, you might want to <strong>install <a href="http://wordpress.org/extend/plugins/wp-donottrack/" title="WP DoNotTrack">WP DoNotTrack</a></strong>, which is a more powerful and flexible solution.</p><p>Have a great day!<br /><a href="http://blog.futtta.be/">frank</a>.</div>';
|
34 |
}
|
35 |
|
36 |
+
if (get_option('lyte_notification','0')!=="2") {
|
37 |
add_action('admin_notices', 'lyte_admin_notice');
|
38 |
+
update_option('lyte_notification','2');
|
39 |
}
|
40 |
|
41 |
function lyte_settings_page() {
|
42 |
+
global $pSize, $pSizeOrder;
|
43 |
?>
|
44 |
<div class="wrap">
|
45 |
<h2><?php _e("WP YouTube Lyte Settings","wp-youtube-lyte") ?></h2>
|
50 |
<form method="post" action="options.php">
|
51 |
<?php settings_fields( 'lyte-settings-group' ); ?>
|
52 |
<table class="form-table">
|
53 |
+
<input type="hidden" name="lyte_notification" value="<?php echo get_option('lyte_notification','0'); ?>" />
|
54 |
|
55 |
<tr valign="top">
|
56 |
<th scope="row">Player size:</th>
|
57 |
<td>
|
58 |
<fieldset><legend class="screen-reader-text"><span><?php _e("Player size","wp-youtube-lyte") ?></span></legend>
|
59 |
+
<?php
|
60 |
+
if (is_bool(get_option('lyte_size'))) { $sel = (int) $pDefault; } else { $sel= (int) get_option('lyte_size'); }
|
61 |
foreach (array("169","43") as $f) {
|
62 |
foreach ($pSizeOrder[$f] as $i) {
|
63 |
$pS=$pSize[$i];
|
64 |
if ($pS[a]===true) {
|
65 |
?>
|
66 |
+
<label title="<?php echo $pS[w]."X".$pS[h]; ?>"><input type="radio" name="lyte_size" class="l_size" value="<?php echo $i."\"";if($i===$sel) echo " checked";echo " /> ".$pS[w]."X".$pS[h]." (".$pS[t];?>)</label><br />
|
67 |
<?php
|
68 |
}
|
69 |
}
|
78 |
<td>
|
79 |
<fieldset>
|
80 |
<legend class="screen-reader-text"><span><?php _e("Show links?","wp-youtube-lyte") ?></span></legend>
|
81 |
+
<label title="Show YouTube-link"><input type="radio" name="lyte_show_links" value="1" <?php if (get_option('lyte_show_links')==="1") echo "checked" ?> /><?php _e(" Add YouTube-link.","wp-youtube-lyte") ?></label><br />
|
82 |
+
<label title="Show YouTube and Ease YouTube link"><input type="radio" name="lyte_show_links" value="2" <?php if (get_option('lyte_show_links')==="2") echo "checked" ?> /><?php _e(" Add both a YouTube and an <a href=\"http://icant.co.uk/easy-youtube/docs/index.html\" target=\"_blank\">Easy YouTube</a>-link.","wp-youtube-lyte") ?></label><br />
|
83 |
+
<label title="Don't include links."><input type="radio" name="lyte_show_links" value="0" <?php if ((get_option('lyte_show_links')!=="1") && (get_option('lyte_show_links')!=="2")) echo "checked" ?> /><?php _e(" Don't add any links.","wp-youtube-lyte") ?></label>
|
84 |
</fieldset>
|
85 |
</td>
|
86 |
</tr>
|
89 |
<td>
|
90 |
<fieldset>
|
91 |
<legend class="screen-reader-text"><span>Left, center or right?</span></legend>
|
92 |
+
<label title="Left"><input type="radio" name="lyte_position" value="0" <?php if (get_option('lyte_position','0')==="0") echo "checked" ?> /><?php _e("Left","wp-youtube-lyte") ?></label><br />
|
93 |
+
<label title="Center"><input type="radio" name="lyte_position" value="1" <?php if (get_option('lyte_position','0')==="1") echo "checked" ?> /><?php _e("Center","wp-youtube-lyte") ?></label>
|
94 |
</fieldset>
|
95 |
</td>
|
96 |
</tr>
|
97 |
<tr valign="top">
|
98 |
+
<th scope="row"><?php _e("Try to force HD (experimental)?","wp-youtube-lyte") ?></th>
|
99 |
<td>
|
100 |
<fieldset>
|
101 |
<legend class="screen-reader-text"><span>HD or not?</span></legend>
|
102 |
+
<label title="Enable HD?"><input type="radio" name="lyte_hidef" value="1" <?php if (get_option('lyte_hidef','0')==="1") echo "checked" ?> /><?php _e("Enable HD","wp-youtube-lyte") ?></label><br />
|
103 |
+
<label title="Don't enable HD playback"><input type="radio" name="lyte_hidef" value="0" <?php if (get_option('lyte_hidef','0')!=="1") echo "checked" ?> /><?php _e("No HD (default)","wp-youtube-lyte") ?></label>
|
104 |
</fieldset>
|
105 |
</td>
|
106 |
</tr>
|
107 |
+
<tr valign="top">
|
108 |
+
<th scope="row"><?php _e("Add microdata?","wp-youtube-lyte") ?></th>
|
109 |
+
<td>
|
110 |
+
<fieldset>
|
111 |
+
<legend class="screen-reader-text"><span>Add video microdata to the HTML?</span></legend>
|
112 |
+
<label title="Sure, add microdata!"><input type="radio" name="lyte_microdata" value="1" <?php if (get_option('lyte_microdata','1')==="1") echo "checked" ?> /><?php _e("Yes (default)","wp-youtube-lyte") ?></label><br />
|
113 |
+
<label title="No microdata in my HTML please."><input type="radio" name="lyte_microdata" value="0" <?php if (get_option('lyte_microdata','1')!=="1") echo "checked" ?> /><?php _e("No microdata, thanks.","wp-youtube-lyte") ?></label>
|
114 |
+
</fieldset>
|
115 |
+
</td>
|
116 |
</tr>
|
117 |
</table>
|
118 |
|
player_sizes.inc.php
CHANGED
@@ -79,7 +79,10 @@ $wSize[4]['depr']=false;
|
|
79 |
$wSize[5]['h']=200;
|
80 |
$wSize[5]['w']=250;
|
81 |
$wSize[5]['depr']=false;
|
82 |
-
$wSize[6]['h']=
|
83 |
-
$wSize[6]['w']=
|
84 |
$wSize[6]['depr']=false;
|
|
|
|
|
|
|
85 |
?>
|
79 |
$wSize[5]['h']=200;
|
80 |
$wSize[5]['w']=250;
|
81 |
$wSize[5]['depr']=false;
|
82 |
+
$wSize[6]['h']=225;
|
83 |
+
$wSize[6]['w']=300;
|
84 |
$wSize[6]['depr']=false;
|
85 |
+
$wSize[7]['h']=300;
|
86 |
+
$wSize[7]['w']=400;
|
87 |
+
$wSize[7]['depr']=false;
|
88 |
?>
|
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, lazy load
|
4 |
Requires at least: 2.9
|
5 |
Tested up to: 3.4.2
|
6 |
-
Stable tag: 1.
|
7 |
|
8 |
High performance YouTube video, playlist and audio-only embeds which don't slow down your blog and offer optimal accessibility.
|
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/2012/04/03/speed-matters-re-evaluating-wp-youtube-lytes-performance/) 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 |
|
@@ -20,12 +20,12 @@ Just add a YouTube-link for a video or [an entire playlist](http://blog.futtta.b
|
|
20 |
* httpv://www.youtube.com/watch?v=_SQkWbRublY#stepSize=-1 (video player, one size smaller than what's configured as default)
|
21 |
* httpv://www.youtube.com/watch?v=_SQkWbRublY?start=20&showinfo=0 (video player, start playing at 20 seconds and don't show title)
|
22 |
|
23 |
-
Or using shortcodes
|
24 |
`[lyte id="_SQkWbRublY" /]`
|
25 |
`[lyte id="_SQkWbRublY" audio="true" /]`
|
26 |
`[lyte id="A486E741B25F8E00" playlist="true" /]`
|
27 |
|
28 |
-
WP YouTube Lyte has been written with optimal performance as primary goal, but has been tested for maximum browser-compatibility (iPad included) while keeping an eye on accessibility. The plugin is fully multi-language, with support for Catalan, Dutch, English, French, German, Hebrew, Romanian, Spanish and Slovene.
|
29 |
|
30 |
Feedback is welcome; see [info in the faq](http://wordpress.org/extend/plugins/wp-youtube-lyte/faq/) for bug reports/ feature requests and feel free to [rate and/or report on compatibility on wordpress.org](http://wordpress.org/extend/plugins/wp-youtube-lyte/).
|
31 |
|
@@ -44,7 +44,7 @@ When playing, HTML5 video will not be visible for everyone (see requirements). I
|
|
44 |
|
45 |
= What are the requirements to see embedded YouTube HTML5 video? =
|
46 |
* It only works in browsers that support the h264 (Safari, Chrome, IE9) or WebM (currently Chrome, Opera and Firefox) video codecs
|
47 |
-
* Your visitor has to be enrolled in the [YouTube html5 beta](http://www.youtube.com/html5)
|
48 |
|
49 |
= Does WP YouTube Lyte protect my visitor's privacy? =
|
50 |
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).
|
@@ -62,11 +62,23 @@ Starting from version 1.1.0 it does; in [Infinite Scroll](http://wordpress.org/e
|
|
62 |
= Can I still integrate with YouTube's JS API? =
|
63 |
This was added as a beta feature in version 1.1.0; add ?enablejsapi=1 to the httpv URL. WP YouTube Lyte will pick this up, and add ?enablejsapi=1&origin=<hostname-of-blog> to the URL of the iFrame with the iFrame id being set to iF_<youtube-video-id>. As soon as your visitors plays the video, you should be able to hook up with the video.
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
= Any bugs/ issues should I know about? =
|
66 |
* Although the widget is available in (very) small sizes, these do not display that great and might, in the near future, be disabled by YouTube as their Terms of Service state that the smallest available embedded player is 200X200 pixels. Use the deprecated smaller sizes at your own risk.
|
67 |
* Having the same YouTube-video on one page can cause WP YouTube Lyte to malfunction (as the YouTube id is used as the div's id in the DOM, and DOM id's are supposed to be unique)
|
68 |
* As youtube-nocookie.com does not serve the HTML5-player, WP YouTube Lyte uses the youtube.com domain (which provides less privacy), but as soon as youtube-nocookie.com serves HTML5-video, this will become the default domain for WP YouTube Lyte again.
|
69 |
* When using the Firefox plugin Karma Blocker, the [video isn't visible when clicking "play", with a warning message being shown instead](http://blog.futtta.be/?p=7584). This is expected behavior and should be solved by tweaking Karma Blocker's configuration.
|
|
|
70 |
|
71 |
= I found a bug/ I would like a feature to be added! =
|
72 |
Just tell me, I like the feedback! Use the [Contact-page on my blog](http://blog.futtta.be/contact/), [leave a comment in a post about wp-youtube-lyte](http://blog.futtta.be/tag/wp-youtube-lyte/) or [create a new topic on the wordpress.org forum](http://wordpress.org/tags/wp-youtube-lyte?forum_id=10#postform).
|
@@ -78,6 +90,14 @@ Just tell me, I like the feedback! Use the [Contact-page on my blog](http://blog
|
|
78 |
|
79 |
== Changelog ==
|
80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
= 1.1.9 =
|
82 |
* privacy enhancement: load thumbnails from the cookie-less i.ytimg.com instead of from the cookie-riddled youtube.com (but there are some caveats, [see FAQ](http://wordpress.org/extend/plugins/wp-youtube-lyte/faq/))
|
83 |
* bugfix: the fullscreen-button did not always appear when playing a video, added the "allowfullscreen" attribute to the iframe (as in the most recent youtube embed code)
|
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, responsive, microdata, videoobject
|
4 |
Requires at least: 2.9
|
5 |
Tested up to: 3.4.2
|
6 |
+
Stable tag: 1.2.0
|
7 |
|
8 |
High performance YouTube video, playlist and audio-only embeds which don't slow down your blog and offer optimal accessibility.
|
9 |
|
10 |
== Description ==
|
11 |
|
12 |
+
WP YouTube Lyte allows you to "lazy load" your video's, by inserting responsive "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/2012/04/03/speed-matters-re-evaluating-wp-youtube-lytes-performance/) 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 |
|
20 |
* httpv://www.youtube.com/watch?v=_SQkWbRublY#stepSize=-1 (video player, one size smaller than what's configured as default)
|
21 |
* httpv://www.youtube.com/watch?v=_SQkWbRublY?start=20&showinfo=0 (video player, start playing at 20 seconds and don't show title)
|
22 |
|
23 |
+
Or using shortcodes:
|
24 |
`[lyte id="_SQkWbRublY" /]`
|
25 |
`[lyte id="_SQkWbRublY" audio="true" /]`
|
26 |
`[lyte id="A486E741B25F8E00" playlist="true" /]`
|
27 |
|
28 |
+
WP YouTube Lyte has been written with optimal performance as primary goal, but has been tested for maximum browser-compatibility (iPad included) while keeping an eye on accessibility. Starting with version 1.2.0 lyte embeds are fully responsive and can automatically embed [videoObject microdata](http://support.google.com/webmasters/bin/answer.py?hl=en&answer=2413309) as well. The plugin is fully multi-language, with support for Catalan, Dutch, English, French, German, Hebrew, Romanian, Spanish and Slovene.
|
29 |
|
30 |
Feedback is welcome; see [info in the faq](http://wordpress.org/extend/plugins/wp-youtube-lyte/faq/) for bug reports/ feature requests and feel free to [rate and/or report on compatibility on wordpress.org](http://wordpress.org/extend/plugins/wp-youtube-lyte/).
|
31 |
|
44 |
|
45 |
= What are the requirements to see embedded YouTube HTML5 video? =
|
46 |
* It only works in browsers that support the h264 (Safari, Chrome, IE9) or WebM (currently Chrome, Opera and Firefox) video codecs
|
47 |
+
* Your visitor has to be enrolled in the [YouTube html5 beta](http://www.youtube.com/html5) except if no Flash in present, in which case YouTube will attempt to fall-back to HTML5 as well
|
48 |
|
49 |
= Does WP YouTube Lyte protect my visitor's privacy? =
|
50 |
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).
|
62 |
= Can I still integrate with YouTube's JS API? =
|
63 |
This was added as a beta feature in version 1.1.0; add ?enablejsapi=1 to the httpv URL. WP YouTube Lyte will pick this up, and add ?enablejsapi=1&origin=<hostname-of-blog> to the URL of the iFrame with the iFrame id being set to iF_<youtube-video-id>. As soon as your visitors plays the video, you should be able to hook up with the video.
|
64 |
|
65 |
+
= How does WP YouTube Lyte support microdata? =
|
66 |
+
* There is a [specific microdata scheme for "videoObject"](http://support.google.com/webmasters/bin/answer.py?hl=en&answer=2413309) which WP YouTube Lyte can add to your page, which Google can use to display the video thumbnail next to the search-result
|
67 |
+
* This is optional and can be disabled in the options page
|
68 |
+
* The videoobject microdata is NOT added for audio-only embeds, playlists or widgets
|
69 |
+
* Google will not always display the thumbnail, this presumably depends of the relevance of the video to the rest of the page.
|
70 |
+
|
71 |
+
= Responsive LYTE embeds =
|
72 |
+
* The video width in posts and pages will adapt to the width of the container (the div) in which your blogposts/ pages are shown. This means that if your theme is responsive, WP YouTube Lyte will follow.
|
73 |
+
* Widgets are not responsive.
|
74 |
+
* if the content div width gets to around 200 pixels, the LYTE UI will become garbled (YouTube requires the minimum embed width to be 200px as well).
|
75 |
+
|
76 |
= Any bugs/ issues should I know about? =
|
77 |
* Although the widget is available in (very) small sizes, these do not display that great and might, in the near future, be disabled by YouTube as their Terms of Service state that the smallest available embedded player is 200X200 pixels. Use the deprecated smaller sizes at your own risk.
|
78 |
* Having the same YouTube-video on one page can cause WP YouTube Lyte to malfunction (as the YouTube id is used as the div's id in the DOM, and DOM id's are supposed to be unique)
|
79 |
* As youtube-nocookie.com does not serve the HTML5-player, WP YouTube Lyte uses the youtube.com domain (which provides less privacy), but as soon as youtube-nocookie.com serves HTML5-video, this will become the default domain for WP YouTube Lyte again.
|
80 |
* When using the Firefox plugin Karma Blocker, the [video isn't visible when clicking "play", with a warning message being shown instead](http://blog.futtta.be/?p=7584). This is expected behavior and should be solved by tweaking Karma Blocker's configuration.
|
81 |
+
* The translations have not been updated entirely for version 1.2.0, this will be included in 1.2.1. Help with translations is always welcome!
|
82 |
|
83 |
= I found a bug/ I would like a feature to be added! =
|
84 |
Just tell me, I like the feedback! Use the [Contact-page on my blog](http://blog.futtta.be/contact/), [leave a comment in a post about wp-youtube-lyte](http://blog.futtta.be/tag/wp-youtube-lyte/) or [create a new topic on the wordpress.org forum](http://wordpress.org/tags/wp-youtube-lyte?forum_id=10#postform).
|
90 |
|
91 |
== Changelog ==
|
92 |
|
93 |
+
= 1.2.0 =
|
94 |
+
* LYTE embeds are now fully responsive
|
95 |
+
* automatic inclusion of [scheme.org microdata (VideoObject)](http://support.google.com/webmasters/bin/answer.py?hl=en&answer=2413309)
|
96 |
+
* even better performance (less requests; was 5, now 3)
|
97 |
+
* updated to current YouTube look & feel
|
98 |
+
* less JavaScript, more CSS
|
99 |
+
* bugfix: all lyte-output is now removed from excerpts
|
100 |
+
|
101 |
= 1.1.9 =
|
102 |
* privacy enhancement: load thumbnails from the cookie-less i.ytimg.com instead of from the cookie-riddled youtube.com (but there are some caveats, [see FAQ](http://wordpress.org/extend/plugins/wp-youtube-lyte/faq/))
|
103 |
* bugfix: the fullscreen-button did not always appear when playing a video, added the "allowfullscreen" attribute to the iframe (as in the most recent youtube embed code)
|
widget.php
CHANGED
@@ -1,9 +1,7 @@
|
|
1 |
<?php
|
2 |
-
require_once(dirname(__FILE__).'/player_sizes.inc.php');
|
3 |
-
|
4 |
class WYLWidget extends WP_Widget {
|
5 |
function WYLWidget() {
|
6 |
-
|
7 |
}
|
8 |
|
9 |
function widget($args, $instance) {
|
@@ -11,14 +9,20 @@ class WYLWidget extends WP_Widget {
|
|
11 |
global $wSize, $wyl_version, $wp_lyte_plugin_url, $lyteSettings;
|
12 |
$qsa="";
|
13 |
|
14 |
-
|
15 |
$WYLtext = apply_filters( 'widget_text', $instance['WYLtext'], $instance );
|
16 |
|
17 |
$WYLsize = apply_filters( 'widget_text', $instance['WYLsize'], $instance );
|
18 |
if ($WYLsize=="") $WYLsize=$wDefault;
|
19 |
|
20 |
$WYLaudio = apply_filters( 'widget_text', $instance['WYLaudio'], $instance );
|
21 |
-
if ($WYLaudio!=="audio")
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
$WYLurl=str_replace("httpv://","http://",$instance['WYLurl']);
|
24 |
|
@@ -39,22 +43,22 @@ class WYLWidget extends WP_Widget {
|
|
39 |
}
|
40 |
|
41 |
if (!empty($qsa)) {
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
|
48 |
-
$
|
|
|
49 |
|
50 |
$lyteSettings['path']=$wp_lyte_plugin_url."lyte/";
|
51 |
?>
|
52 |
-
|
53 |
-
<?php echo $
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
<?php echo $after_widget; ?>
|
58 |
<?php
|
59 |
lyte_initer();
|
60 |
}
|
@@ -66,12 +70,13 @@ class WYLWidget extends WP_Widget {
|
|
66 |
$instance['WYLsize'] = strip_tags($new_instance['WYLsize']);
|
67 |
$instance['WYLaudio'] = strip_tags($new_instance['WYLaudio']);
|
68 |
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
73 |
|
74 |
-
|
75 |
}
|
76 |
|
77 |
function form($instance) {
|
@@ -100,8 +105,9 @@ class WYLWidget extends WP_Widget {
|
|
100 |
$selected="";
|
101 |
}
|
102 |
unset($deprecated);
|
103 |
-
if ($wSize[$x]['depr']
|
104 |
-
|
|
|
105 |
$x++;
|
106 |
}
|
107 |
?>
|
1 |
<?php
|
|
|
|
|
2 |
class WYLWidget extends WP_Widget {
|
3 |
function WYLWidget() {
|
4 |
+
parent::WP_Widget(false, $name = 'WP YouTube Lyte');
|
5 |
}
|
6 |
|
7 |
function widget($args, $instance) {
|
9 |
global $wSize, $wyl_version, $wp_lyte_plugin_url, $lyteSettings;
|
10 |
$qsa="";
|
11 |
|
12 |
+
$WYLtitle = apply_filters('widget_title', $instance['WYLtitle']);
|
13 |
$WYLtext = apply_filters( 'widget_text', $instance['WYLtext'], $instance );
|
14 |
|
15 |
$WYLsize = apply_filters( 'widget_text', $instance['WYLsize'], $instance );
|
16 |
if ($WYLsize=="") $WYLsize=$wDefault;
|
17 |
|
18 |
$WYLaudio = apply_filters( 'widget_text', $instance['WYLaudio'], $instance );
|
19 |
+
if ($WYLaudio!=="audio") {
|
20 |
+
$wrapperClass = " lidget";
|
21 |
+
$wHeight = $wSize[$WYLsize]['h'];
|
22 |
+
} else {
|
23 |
+
$wrapperClass = "-audio lidget";
|
24 |
+
$wHeight = "38";
|
25 |
+
}
|
26 |
|
27 |
$WYLurl=str_replace("httpv://","http://",$instance['WYLurl']);
|
28 |
|
43 |
}
|
44 |
|
45 |
if (!empty($qsa)) {
|
46 |
+
$esc_arr=array("&" => "\&", "?" => "\?", "=" => "\=");
|
47 |
+
$qsaClass=" qsa_".strtr($qsa,$esc_arr);
|
48 |
+
} else {
|
49 |
+
$qsaClass="";
|
50 |
+
}
|
51 |
|
52 |
+
$WYL_dom_id="YLW_".$WYLid;
|
53 |
+
$WYLthumb="http://img.youtube.com/vi/".$WYLid."/mqdefault.jpg";
|
54 |
|
55 |
$lyteSettings['path']=$wp_lyte_plugin_url."lyte/";
|
56 |
?>
|
57 |
+
<?php echo $before_widget; ?>
|
58 |
+
<?php if ( $WYLtitle ) echo $before_title . $WYLtitle . $after_title; ?>
|
59 |
+
<div class="lyte-wrapper<?php echo $wrapperClass; ?>" style="width:<?php echo $wSize[$WYLsize]['w']; ?>px; height:<?php echo $wHeight; ?>px; min-width:200px; max-width:100%;"><div class="lyMe <?php echo $WYLaudio; echo $qsaClass; ?>" id="<?php echo $WYL_dom_id; ?>"><div id="lyte_<?php echo $WYLid; ?>" data-src="<?php echo $WYLthumb;?>" class="pL"><div class="play"></div><div class="ctrl"><div class="Lctrl"></div></div></div></div><noscript><a href="http://youtu.be/<?php echo $WYLid;?>"><img src="<?php echo $WYLthumb; ?>" alt="" /></a></noscript></div>
|
60 |
+
<div><?php echo $WYLtext ?></div>
|
61 |
+
<?php echo $after_widget; ?>
|
|
|
62 |
<?php
|
63 |
lyte_initer();
|
64 |
}
|
70 |
$instance['WYLsize'] = strip_tags($new_instance['WYLsize']);
|
71 |
$instance['WYLaudio'] = strip_tags($new_instance['WYLaudio']);
|
72 |
|
73 |
+
if ( current_user_can('unfiltered_html') ) {
|
74 |
+
$instance['WYLtext'] = $new_instance['WYLtext'];
|
75 |
+
} else {
|
76 |
+
$instance['WYLtext'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['WYLtext']) ) );
|
77 |
+
}
|
78 |
|
79 |
+
return $instance;
|
80 |
}
|
81 |
|
82 |
function form($instance) {
|
105 |
$selected="";
|
106 |
}
|
107 |
unset($deprecated);
|
108 |
+
if ($wSize[$x]['depr']!==true) {
|
109 |
+
echo "<option value=\"".$x."\"".$selected.">".$wSize[$x]['w']."X".$wSize[$x]['h']."</option>";
|
110 |
+
}
|
111 |
$x++;
|
112 |
}
|
113 |
?>
|
wp-youtube-lyte.php
CHANGED
@@ -4,31 +4,45 @@ 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.
|
8 |
Author URI: http://blog.futtta.be/
|
9 |
Text Domain: wp-youtube-lyte
|
10 |
Domain Path: /languages
|
11 |
*/
|
12 |
|
13 |
$debug=false;
|
|
|
|
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
if (!$debug) {
|
16 |
-
$wyl_version
|
17 |
$wyl_file="lyte-min.js";
|
18 |
} else {
|
19 |
$wyl_version=rand()/1000;
|
20 |
$wyl_file="lyte.js";
|
21 |
-
|
|
|
22 |
|
|
|
23 |
$plugin_dir = basename(dirname(__FILE__)).'/languages';
|
24 |
load_plugin_textdomain( 'wp-youtube-lyte', null, $plugin_dir );
|
25 |
-
|
26 |
$wp_lyte_plugin_url = trailingslashit(get_bloginfo('wpurl')) . PLUGINDIR . '/' . dirname(plugin_basename(__FILE__)) . '/';
|
27 |
-
|
28 |
require_once(dirname(__FILE__).'/player_sizes.inc.php');
|
29 |
require_once(dirname(__FILE__).'/widget.php');
|
30 |
|
31 |
-
|
|
|
32 |
if ((is_bool($oSize)) || ($pSize[$oSize]['a']===false)) { $sel = (int) $pDefault; } else { $sel=$oSize; }
|
33 |
|
34 |
$pSizeFormat=$pSize[$sel]['f'];
|
@@ -40,35 +54,34 @@ foreach ($pSizeOrder[$pSizeFormat] as $sizeId) {
|
|
40 |
$j++;
|
41 |
}
|
42 |
|
|
|
43 |
$lyteSettings['sizeArray']=$sArray;
|
44 |
$lyteSettings['selSize']=$selSize;
|
45 |
$lyteSettings['path']=$wp_lyte_plugin_url.'lyte/';
|
46 |
-
$lyteSettings['links']=get_option('
|
47 |
$lyteSettings['file']=$wyl_file."?wyl_version=".$wyl_version;
|
48 |
-
$lyteSettings['
|
|
|
|
|
|
|
|
|
49 |
|
|
|
50 |
function lyte_parse($the_content,$doExcerpt=false) {
|
51 |
global $lyteSettings;
|
52 |
|
53 |
$urlArr=parse_url($lyteSettings['path']);
|
54 |
-
$origin=$urlArr[scheme]."://".$urlArr[host]."/";
|
55 |
|
56 |
if((strpos($the_content, "httpv")!==FALSE)||(strpos($the_content, "httpa")!==FALSE)) {
|
57 |
$char_codes = array('×','–');
|
58 |
$replacements = array("x", "--");
|
59 |
$the_content=str_replace($char_codes, $replacements, $the_content);
|
|
|
|
|
60 |
|
61 |
-
|
62 |
-
|
63 |
-
} else {
|
64 |
-
$hidefClass="";
|
65 |
-
}
|
66 |
-
|
67 |
-
if ( is_ssl() ) {
|
68 |
-
$scheme="https";
|
69 |
-
} else {
|
70 |
-
$scheme="http";
|
71 |
-
}
|
72 |
|
73 |
$lytes_regexp="/(?:<p>)?http(v|a):\/\/([a-zA-Z0-9\-\_]+\.|)(youtube|youtu)(\.com|\.be)\/(((watch(\?v\=|\/v\/)|.+?v\=|)([a-zA-Z0-9\-\_]{11}))|(playlist\?list\=(PL[a-zA-Z0-9\-\_]*)))([^\s<]*)(<?:\/p>)?/";
|
74 |
|
@@ -81,9 +94,14 @@ function lyte_parse($the_content,$doExcerpt=false) {
|
|
81 |
preg_match("/enablejsapi\=([0-1]{1})/",$match[12],$jsapi);
|
82 |
|
83 |
$qsa="";
|
84 |
-
if ($showinfo[0])
|
85 |
-
|
86 |
-
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
if (!empty($qsa)) {
|
89 |
$esc_arr=array("&" => "\&", "?" => "\?", "=" => "\=");
|
@@ -110,7 +128,9 @@ function lyte_parse($the_content,$doExcerpt=false) {
|
|
110 |
if ($match[1]!=="a") {
|
111 |
$divHeight=$lyteSettings[3];
|
112 |
$audioClass="";
|
|
|
113 |
} else {
|
|
|
114 |
$audioClass=" audio";
|
115 |
$divHeight=38;
|
116 |
}
|
@@ -124,12 +144,12 @@ function lyte_parse($the_content,$doExcerpt=false) {
|
|
124 |
switch ($lyteSettings['links']) {
|
125 |
case "0":
|
126 |
$noscript_post="<br />".__("Watch this playlist on YouTube","wp-youtube-lyte");
|
127 |
-
$noscript="<noscript><a href=\"".$scheme."://youtube.com/playlist?list=PL".$vid."\">".$noscript_post."</a> ".$NSbanner."</noscript>";
|
128 |
$lytelinks_txt="";
|
129 |
break;
|
130 |
default:
|
131 |
$noscript="<noscript>".$NSbanner."</noscript>";
|
132 |
-
$lytelinks_txt="<div class=\"lL\" style=\"width:".$lyteSettings[2]."px
|
133 |
}
|
134 |
} else if ($match[9]!="") {
|
135 |
$plClass="";
|
@@ -137,52 +157,150 @@ function lyte_parse($the_content,$doExcerpt=false) {
|
|
137 |
switch ($lyteSettings['links']) {
|
138 |
case "0":
|
139 |
$noscript_post="<br />".__("Watch this video on YouTube","wp-youtube-lyte");
|
140 |
-
$lytelinks_txt="<div class=\"lL\" style=\"width:".$lyteSettings[2]."px
|
141 |
break;
|
142 |
case "2":
|
143 |
$noscript_post="";
|
144 |
-
$lytelinks_txt="<div class=\"lL\" style=\"width:".$lyteSettings[2]."px
|
145 |
break;
|
146 |
default:
|
147 |
$noscript_post="";
|
148 |
-
$lytelinks_txt="<div class=\"lL\" style=\"width:".$lyteSettings[2]."px
|
149 |
}
|
150 |
|
151 |
-
$noscript="<noscript><a href=\"".$scheme."://youtu.be/".$vid."\"><img src=\"".$scheme."://i.ytimg.com/vi/".$vid."/0.jpg\" alt=\"\" width=\"".$lyteSettings[2]."\" height=\"".$NSimgHeight."\" />".$noscript_post."</a> ".$NSbanner."</noscript>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
}
|
153 |
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
|
156 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
$the_content = preg_replace($lytes_regexp, $lytetemplate, $the_content, 1);
|
158 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
lyte_initer();
|
160 |
}
|
161 |
-
|
162 |
}
|
163 |
|
|
|
164 |
function lyte_initer() {
|
|
|
165 |
if (!$lynited) {
|
166 |
$lynited=true;
|
167 |
add_action('wp_footer', 'lyte_init');
|
168 |
}
|
169 |
}
|
170 |
|
|
|
171 |
function lyte_init() {
|
172 |
global $lyteSettings;
|
173 |
-
|
174 |
-
$pos="auto";
|
175 |
-
}
|
176 |
-
echo "<script type=\"text/javascript\">var bU='".$lyteSettings['path']."';style = document.createElement('style');style.type = 'text/css';rules = document.createTextNode('.lyte img {border:0px !important;padding:0px;spacing:0px;margin:0px;display:inline;background-color:transparent;max-width:100%} .lL {margin:5px ".$pos.";} .lP {background-color:#fff;margin:5px ".$pos.";} .pL {cursor:pointer;text-align:center;overflow:hidden;position:relative;margin:0px !important;} .tC {left:0;top:0;position:absolute;width:100%;background-color:rgba(0,0,0,0.6);} .tT {padding:5px 10px;font-size:16px;color:#ffffff;font-family:sans-serif;text-align:left;} .ctrl {position:absolute;left:0px;bottom:0px;}');if(style.styleSheet) { style.styleSheet.cssText = rules.nodeValue;} else {style.appendChild(rules);}document.getElementsByTagName('head')[0].appendChild(style);</script>";
|
177 |
echo "<script type=\"text/javascript\" async=true src=\"".$lyteSettings['path'].$lyteSettings['file']."\"></script>";
|
178 |
}
|
179 |
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
|
185 |
-
/**
|
186 |
function shortcode_lyte($atts) {
|
187 |
extract(shortcode_atts(array(
|
188 |
"id" => '',
|
@@ -196,11 +314,39 @@ function shortcode_lyte($atts) {
|
|
196 |
return lyte_parse($proto.'://www.youtube.com/'.$action.$id);
|
197 |
}
|
198 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
if ( is_admin() ) {
|
200 |
require_once(dirname(__FILE__).'/options.php');
|
201 |
} else {
|
202 |
add_filter('the_content', 'lyte_parse', 4);
|
203 |
-
add_filter('the_excerpt', 'lyte_parse_excerpt', 4);
|
204 |
add_shortcode("lyte", "shortcode_lyte");
|
|
|
|
|
205 |
}
|
206 |
?>
|
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.2.0
|
8 |
Author URI: http://blog.futtta.be/
|
9 |
Text Domain: wp-youtube-lyte
|
10 |
Domain Path: /languages
|
11 |
*/
|
12 |
|
13 |
$debug=false;
|
14 |
+
$lyte_version="1.2.0";
|
15 |
+
$lyte_db_version=get_option('lyte_version','none');
|
16 |
|
17 |
+
/** have we updated? */
|
18 |
+
if ($lyte_db_version !== $lyte_version) {
|
19 |
+
switch($lyte_db_version) {
|
20 |
+
case "none":
|
21 |
+
lyte_options_update();
|
22 |
+
}
|
23 |
+
update_option('lyte_version',$lyte_version);
|
24 |
+
$lyte_db_version=$lyte_version;
|
25 |
+
}
|
26 |
+
|
27 |
+
/** are we in debug-mode */
|
28 |
if (!$debug) {
|
29 |
+
$wyl_version=$lyte_version;
|
30 |
$wyl_file="lyte-min.js";
|
31 |
} else {
|
32 |
$wyl_version=rand()/1000;
|
33 |
$wyl_file="lyte.js";
|
34 |
+
lyte_rm_cache();
|
35 |
+
}
|
36 |
|
37 |
+
/** get paths, language and includes */
|
38 |
$plugin_dir = basename(dirname(__FILE__)).'/languages';
|
39 |
load_plugin_textdomain( 'wp-youtube-lyte', null, $plugin_dir );
|
|
|
40 |
$wp_lyte_plugin_url = trailingslashit(get_bloginfo('wpurl')) . PLUGINDIR . '/' . dirname(plugin_basename(__FILE__)) . '/';
|
|
|
41 |
require_once(dirname(__FILE__).'/player_sizes.inc.php');
|
42 |
require_once(dirname(__FILE__).'/widget.php');
|
43 |
|
44 |
+
/** get default embed size and build array to change size later if requested */
|
45 |
+
$oSize = (int) get_option('lyte_size');
|
46 |
if ((is_bool($oSize)) || ($pSize[$oSize]['a']===false)) { $sel = (int) $pDefault; } else { $sel=$oSize; }
|
47 |
|
48 |
$pSizeFormat=$pSize[$sel]['f'];
|
54 |
$j++;
|
55 |
}
|
56 |
|
57 |
+
/** get other options and push in array*/
|
58 |
$lyteSettings['sizeArray']=$sArray;
|
59 |
$lyteSettings['selSize']=$selSize;
|
60 |
$lyteSettings['path']=$wp_lyte_plugin_url.'lyte/';
|
61 |
+
$lyteSettings['links']=get_option('lyte_show_links');
|
62 |
$lyteSettings['file']=$wyl_file."?wyl_version=".$wyl_version;
|
63 |
+
$lyteSettings['ratioClass']= ( $pSizeFormat==="43" ) ? " fourthree" : "";
|
64 |
+
$lyteSettings['pos']= ( get_option('lyte_position','0')==="1" ) ? "margin:5px auto;" : "margin:5px;";
|
65 |
+
$lyteSettings['microdata']=get_option('lyte_microdata','1');
|
66 |
+
$lyteSettings['hidef']=get_option('lyte_hidef',0);
|
67 |
+
$lyteSettings['scheme'] = ( is_ssl() ) ? "https" : "http";
|
68 |
|
69 |
+
/* main function to parse the content, searching and replacing httpv-links */
|
70 |
function lyte_parse($the_content,$doExcerpt=false) {
|
71 |
global $lyteSettings;
|
72 |
|
73 |
$urlArr=parse_url($lyteSettings['path']);
|
74 |
+
$origin=$urlArr['scheme']."://".$urlArr['host']."/";
|
75 |
|
76 |
if((strpos($the_content, "httpv")!==FALSE)||(strpos($the_content, "httpa")!==FALSE)) {
|
77 |
$char_codes = array('×','–');
|
78 |
$replacements = array("x", "--");
|
79 |
$the_content=str_replace($char_codes, $replacements, $the_content);
|
80 |
+
|
81 |
+
$hidefClass = ($lyteSettings['hidef']==="1") ? " hidef" : "";
|
82 |
|
83 |
+
$postID = get_the_ID();
|
84 |
+
$toCache_index=array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
$lytes_regexp="/(?:<p>)?http(v|a):\/\/([a-zA-Z0-9\-\_]+\.|)(youtube|youtu)(\.com|\.be)\/(((watch(\?v\=|\/v\/)|.+?v\=|)([a-zA-Z0-9\-\_]{11}))|(playlist\?list\=(PL[a-zA-Z0-9\-\_]*)))([^\s<]*)(<?:\/p>)?/";
|
87 |
|
94 |
preg_match("/enablejsapi\=([0-1]{1})/",$match[12],$jsapi);
|
95 |
|
96 |
$qsa="";
|
97 |
+
if (!empty($showinfo[0])) {
|
98 |
+
$qsa="&".$showinfo[0];
|
99 |
+
$titleClass=" hidden";
|
100 |
+
} else {
|
101 |
+
$titleClass="";
|
102 |
+
}
|
103 |
+
if (!empty($start[0])) $qsa.="&".$start[0];
|
104 |
+
if (!empty($jsapi[0])) $qsa.="&".$jsapi[0]."&origin=".$origin;
|
105 |
|
106 |
if (!empty($qsa)) {
|
107 |
$esc_arr=array("&" => "\&", "?" => "\?", "=" => "\=");
|
128 |
if ($match[1]!=="a") {
|
129 |
$divHeight=$lyteSettings[3];
|
130 |
$audioClass="";
|
131 |
+
$audio=false;
|
132 |
} else {
|
133 |
+
$audio=true;
|
134 |
$audioClass=" audio";
|
135 |
$divHeight=38;
|
136 |
}
|
144 |
switch ($lyteSettings['links']) {
|
145 |
case "0":
|
146 |
$noscript_post="<br />".__("Watch this playlist on YouTube","wp-youtube-lyte");
|
147 |
+
$noscript="<noscript><a href=\"".$lyteSettings['scheme']."://youtube.com/playlist?list=PL".$vid."\">".$noscript_post."</a> ".$NSbanner."</noscript>";
|
148 |
$lytelinks_txt="";
|
149 |
break;
|
150 |
default:
|
151 |
$noscript="<noscript>".$NSbanner."</noscript>";
|
152 |
+
$lytelinks_txt="<div class=\"lL\" style=\"width:".$lyteSettings[2]."px;".$lyteSettings['pos']."\">".__("Watch this playlist","wp-youtube-lyte")." <a href=\"".$lyteSettings['scheme']."://www.youtube.com/playlist?list=PL".$vid."\">".__("on YouTube","wp-youtube-lyte")."</a></div>";
|
153 |
}
|
154 |
} else if ($match[9]!="") {
|
155 |
$plClass="";
|
157 |
switch ($lyteSettings['links']) {
|
158 |
case "0":
|
159 |
$noscript_post="<br />".__("Watch this video on YouTube","wp-youtube-lyte");
|
160 |
+
$lytelinks_txt="<div class=\"lL\" style=\"width:".$lyteSettings[2]."px;".$lyteSettings['pos']."\"></div>";
|
161 |
break;
|
162 |
case "2":
|
163 |
$noscript_post="";
|
164 |
+
$lytelinks_txt="<div class=\"lL\" style=\"width:".$lyteSettings[2]."px;".$lyteSettings['pos']."\">".__("Watch this video","wp-youtube-lyte")." <a href=\"".$lyteSettings['scheme']."://youtu.be/".$vid."\">".__("on YouTube","wp-youtube-lyte")."</a> ".__("or on","wp-youtube-lyte")." <a href=\"http://icant.co.uk/easy-youtube/?http://www.youtube.com/watch?v=".$vid."\">Easy Youtube</a>.</div>";
|
165 |
break;
|
166 |
default:
|
167 |
$noscript_post="";
|
168 |
+
$lytelinks_txt="<div class=\"lL\" style=\"width:".$lyteSettings[2]."px;".$lyteSettings['pos']."\">".__("Watch this video","wp-youtube-lyte")." <a href=\"".$lyteSettings['scheme']."://youtu.be/".$vid."\">".__("on YouTube","wp-youtube-lyte")."</a>.</div>";
|
169 |
}
|
170 |
|
171 |
+
$noscript="<noscript><a href=\"".$lyteSettings['scheme']."://youtu.be/".$vid."\"><img src=\"".$lyteSettings['scheme']."://i.ytimg.com/vi/".$vid."/0.jpg\" alt=\"\" width=\"".$lyteSettings[2]."\" height=\"".$NSimgHeight."\" />".$noscript_post."</a> ".$NSbanner."</noscript>";
|
172 |
+
}
|
173 |
+
|
174 |
+
/** logic to get video info from cache or get it from YouTube and set it */
|
175 |
+
if ( $postID ) {
|
176 |
+
// Check for a cached result (stored in the post meta)
|
177 |
+
$cachekey = '_lyte_' . $vid;
|
178 |
+
$yt_resp = get_post_meta( $postID, $cachekey, true );
|
179 |
+
if (!empty($yt_resp)) {
|
180 |
+
$yt_resp = gzuncompress(base64_decode($yt_resp));
|
181 |
+
}
|
182 |
+
} else {
|
183 |
+
$yt_resp = "";
|
184 |
}
|
185 |
|
186 |
+
if ( empty( $yt_resp ) ) {
|
187 |
+
// get info from youtube
|
188 |
+
$yt_api_base = "http://gdata.youtube.com/feeds/api/";
|
189 |
+
|
190 |
+
if ($plClass===" playlist") {
|
191 |
+
$yt_api_target = "playlists/".$vid."?v=2&alt=json&fields=id,title,author,updated,media:group(media:thumbnail)";
|
192 |
+
} else {
|
193 |
+
$yt_api_target = "videos/".$vid."?v=2&alt=json&fields=id,title,published,content,media:group(media:description,yt:duration,yt:aspectRatio),author(name)";
|
194 |
+
}
|
195 |
+
|
196 |
+
$yt_api_url = $yt_api_base.$yt_api_target;
|
197 |
+
$yt_resp = wp_remote_get($yt_api_url);
|
198 |
+
|
199 |
+
// check if we got through
|
200 |
+
if (is_wp_error($yt_resp)) {
|
201 |
+
$yt_resp="";
|
202 |
+
} else {
|
203 |
+
$yt_resp = wp_remote_retrieve_body($yt_resp);
|
204 |
|
205 |
+
if ( $postID ) {
|
206 |
+
// we can cache the result
|
207 |
+
|
208 |
+
// first add timestamp
|
209 |
+
$yt_resp_array=json_decode($yt_resp,true);
|
210 |
+
$yt_resp_array['lyte_date_added']=time();
|
211 |
+
$yt_resp_precache=json_encode($yt_resp_array);
|
212 |
+
|
213 |
+
// then gzip + base64 (to limit amount of data + solve problems with wordpress removing slashes)
|
214 |
+
$yt_resp_precache=base64_encode(gzcompress($yt_resp_precache));
|
215 |
+
|
216 |
+
// and do the actual caching
|
217 |
+
$toCache = ( $yt_resp_precache ) ? $yt_resp_precache : '{{unknown}}';
|
218 |
+
update_post_meta( $postID, $cachekey, $toCache );
|
219 |
+
|
220 |
+
// and finally add new cache-entry to toCache_index which will be added to lyte_cache_index pref
|
221 |
+
$toCache_index[]=$cachekey;
|
222 |
+
}
|
223 |
+
}
|
224 |
+
}
|
225 |
+
|
226 |
+
// If there was a result from youtube or from cache, use it
|
227 |
+
if ( $yt_resp ) {
|
228 |
+
$yt_resp_array=json_decode($yt_resp,true);
|
229 |
+
if ($plClass===" playlist") {
|
230 |
+
$yt_title="Playlist: ".sanitize_text_field($yt_resp_array['feed']['title']['$t']);
|
231 |
+
$thumbUrl=esc_url($yt_resp_array['feed']['media$group']['media$thumbnail'][2]['url']);
|
232 |
+
$dateField=sanitize_text_field($yt_resp_array['feed']['updated']['$t']);
|
233 |
+
$duration="";
|
234 |
+
$description=$yt_title;
|
235 |
+
} else {
|
236 |
+
$yt_title=sanitize_text_field($yt_resp_array['entry']['title']['$t']);
|
237 |
+
$thumbUrl=esc_url($lyteSettings['scheme']."://i.ytimg.com/vi/".$vid."/0.jpg");
|
238 |
+
$dateField=sanitize_text_field($yt_resp_array['entry']['published']['$t']);
|
239 |
+
$duration="T".sanitize_text_field($yt_resp_array['entry']['media$group']['yt$duration']['seconds'])."S";
|
240 |
+
$description=sanitize_text_field($yt_resp_array['entry']['media$group']['media$description']['$t']);
|
241 |
+
}
|
242 |
+
}
|
243 |
+
|
244 |
+
if ($audio===true) {
|
245 |
+
$wrapper="<div class=\"lyte-wrapper-audio\" style=\"width:".$lyteSettings[2]."px;max-width:100%;overflow:hidden;height:38px;".$lyteSettings['pos']."\">";
|
246 |
+
} else {
|
247 |
+
$wrapper="<div class=\"lyte-wrapper".$lyteSettings['ratioClass']."\" style=\"width:".$lyteSettings[2]."px;max-width: 100%;".$lyteSettings['pos']."\">";
|
248 |
+
}
|
249 |
+
|
250 |
+
if ($doExcerpt) {
|
251 |
+
$lytetemplate="";
|
252 |
+
} elseif (($audio!==true)&&($plClass!==" playlist")&&($lyteSettings['microdata']==="1")) {
|
253 |
+
$lytetemplate = $wrapper."<div class=\"lyMe".$audioClass.$hidefClass.$plClass.$qsaClass."\" id=\"WYL_".$vid."\" itemprop=\"video\" itemscope itemtype=\"http://schema.org/VideoObject\"><meta itemprop=\"duration\" content=\"".$duration."\" /><meta itemprop=\"thumbnailUrl\" content=\"".$thumbUrl."\" /><meta itemprop=\"embedURL\" content=\"http://www.youtube.com/embed/".$vid."\" /><meta itemprop=\"uploadDate\" content=\"".$dateField."\" /><div id=\"lyte_".$vid."\" data-src=\"".$thumbUrl."\" class=\"pL\"><div class=\"tC".$titleClass."\"><div class=\"tT\" itemprop=\"name\">".$yt_title."</div></div><div class=\"play\"></div><div class=\"ctrl\"><div class=\"Lctrl\"></div><div class=\"Rctrl\"></div></div></div>".$noscript."<meta itemprop=\"description\" content=\"".$description."\"></div></div>".$lytelinks_txt;
|
254 |
+
} else {
|
255 |
+
$lytetemplate = $wrapper."<div class=\"lyMe".$audioClass.$hidefClass.$plClass.$qsaClass."\" id=\"WYL_".$vid."\"><div id=\"lyte_".$vid."\" data-src=\"".$thumbUrl."\" class=\"pL\"><div class=\"tC".$titleClass."\"><div class=\"tT\">".$yt_title."</div></div><div class=\"play\"></div><div class=\"ctrl\"><div class=\"Lctrl\"></div><div class=\"Rctrl\"></div></div></div>".$noscript."</div></div>".$lytelinks_txt;
|
256 |
+
}
|
257 |
$the_content = preg_replace($lytes_regexp, $lytetemplate, $the_content, 1);
|
258 |
+
}
|
259 |
+
|
260 |
+
// update lyte_cache_index
|
261 |
+
if ((is_array($toCache_index))&&(!empty($toCache_index))) {
|
262 |
+
$lyte_cache=json_decode(get_option('lyte_cache_index'),true);
|
263 |
+
$lyte_cache[$postID]=$toCache_index;
|
264 |
+
update_option('lyte_cache_index',json_encode($lyte_cache));
|
265 |
+
}
|
266 |
lyte_initer();
|
267 |
}
|
268 |
+
return $the_content;
|
269 |
}
|
270 |
|
271 |
+
/* only add js/css once and only if needed */
|
272 |
function lyte_initer() {
|
273 |
+
global $lynited;
|
274 |
if (!$lynited) {
|
275 |
$lynited=true;
|
276 |
add_action('wp_footer', 'lyte_init');
|
277 |
}
|
278 |
}
|
279 |
|
280 |
+
/* actual initialization */
|
281 |
function lyte_init() {
|
282 |
global $lyteSettings;
|
283 |
+
echo "<script type=\"text/javascript\">var bU='".$lyteSettings['path']."';style = document.createElement('style');style.type = 'text/css';rules = document.createTextNode(\".lyte,.lyMe{position:relative;padding-bottom:56.25%;height:0;overflow:hidden;background-color:#777;} .fourthree .lyMe, .fourthree .lyte {padding-bottom:75%;} .lidget{margin-bottom:5px;} .lidget .lyte, .widget .lyMe {padding-bottom:0!important;height:100%!important;} .lyte-wrapper-audio .lyte{height:38px!important;overflow:hidden;padding:0!important} .lyte iframe,.lyte .pL{position:absolute;top:0;left:0;width:100%;height:100%;background:no-repeat scroll center #000;background-size:cover;cursor:pointer} .tC{background-color:rgba(0,0,0,0.5);left:0;position:absolute;top:0;width:100%} .tT{color:#FFF;font-family:sans-serif;font-size:12px;height:auto;text-align:left;padding:5px 10px} .tT:hover{text-decoration:underline} .play{background:no-repeat scroll 0 0 transparent;width:90px;height:62px;position:absolute;left:43%;left:calc(50% - 45px);left:-webkit-calc(50% - 45px);top:38%;top:calc(50% - 31px);top:-webkit-calc(50% - 31px);} .widget .play {top:30%;top:calc(45% - 31px);top:-webkit-calc(45% - 31px);transform:scale(0.6);-webkit-transform:scale(0.6);-ms-transform:scale(0.6);} .lyte:hover .play{background-position:0 -65px} .audio .pL{max-height:38px!important} .audio iframe{height:438px!important} .ctrl{background:repeat scroll 0 -215px transparent;width:100%;height:40px;bottom:0;left:0;position:absolute} .Lctrl{background:no-repeat scroll 0 -132px transparent;width:158px;height:40px;bottom:0;left:0;position:absolute} .Rctrl{background:no-repeat scroll -42px -174px transparent;width:117px;height:40px;bottom:0;right:0;position:absolute} .audio .play,.audio .tC{display:none} .hidden{display:none}\" );if(style.styleSheet) { style.styleSheet.cssText = rules.nodeValue;} else {style.appendChild(rules);}document.getElementsByTagName('head')[0].appendChild(style);</script>";
|
|
|
|
|
|
|
284 |
echo "<script type=\"text/javascript\" async=true src=\"".$lyteSettings['path'].$lyteSettings['file']."\"></script>";
|
285 |
}
|
286 |
|
287 |
+
/** override default wp_trim_excerpt to have lyte_parse remove the httpv-links */
|
288 |
+
function lyte_trim_excerpt($text) {
|
289 |
+
global $post;
|
290 |
+
if ( '' == $text ) {
|
291 |
+
$text = get_the_content('');
|
292 |
+
$text = lyte_parse($text, true);
|
293 |
+
$text = strip_shortcodes( $text );
|
294 |
+
$text = apply_filters('the_content', $text);
|
295 |
+
$text = str_replace(']]>', ']]>', $text);
|
296 |
+
$excerpt_length = apply_filters('excerpt_length', 55);
|
297 |
+
$excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
|
298 |
+
$text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
|
299 |
+
}
|
300 |
+
return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
|
301 |
+
}
|
302 |
|
303 |
+
/** Lyte shortcode */
|
304 |
function shortcode_lyte($atts) {
|
305 |
extract(shortcode_atts(array(
|
306 |
"id" => '',
|
314 |
return lyte_parse($proto.'://www.youtube.com/'.$action.$id);
|
315 |
}
|
316 |
|
317 |
+
/** update functions */
|
318 |
+
/** upgrade function for 1.1.x to 1.2.x */
|
319 |
+
function lyte_options_update() {
|
320 |
+
if (get_option('size')!==false) {
|
321 |
+
foreach (array('size','show_links','position','hidef','notification') as $oldOptionName) {
|
322 |
+
$oldOptionValue=get_option($oldOptionName);
|
323 |
+
$newOptionName="lyte_".$oldOptionName;
|
324 |
+
update_option($newOptionName,$oldOptionValue);
|
325 |
+
delete_option($oldOptionName);
|
326 |
+
}
|
327 |
+
}
|
328 |
+
}
|
329 |
+
|
330 |
+
/** function to clean YT responses from cache */
|
331 |
+
function lyte_rm_cache() {
|
332 |
+
$lyte_posts=json_decode(get_option('lyte_cache_index'),true);
|
333 |
+
if (is_array($lyte_posts)){
|
334 |
+
foreach ($lyte_posts as $postID => $lyte_post) {
|
335 |
+
foreach ($lyte_post as $cachekey) {
|
336 |
+
delete_post_meta($postID, $cachekey);
|
337 |
+
}
|
338 |
+
}
|
339 |
+
delete_option('lyte_cache_index');
|
340 |
+
}
|
341 |
+
}
|
342 |
+
|
343 |
+
/** hooking it all up to wordpress */
|
344 |
if ( is_admin() ) {
|
345 |
require_once(dirname(__FILE__).'/options.php');
|
346 |
} else {
|
347 |
add_filter('the_content', 'lyte_parse', 4);
|
|
|
348 |
add_shortcode("lyte", "shortcode_lyte");
|
349 |
+
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
|
350 |
+
add_filter('get_the_excerpt', 'lyte_trim_excerpt');
|
351 |
}
|
352 |
?>
|