Version Description
- Added playlist support in the WP YouTube Lyte widget (forget to add it really, thanks to Ed Dingwall to remind me)
- Added an alternative lytesprite version, created by Claes from PCPLAY.se. To switch, rename lyte/lytesprite.png to lyte/lytesprite_orig.png and then rename lyte/lytesprite_claes.png to lyte/lytesprite.png.
- Fixed some PHP notices in widget.php
Download this release
Release Info
Developer | futtta |
Plugin | WP YouTube Lyte |
Version | 1.3.2 |
Comparing to | |
See all releases |
Code changes from version 1.3.1 to 1.3.2
- lyte/lyte-min.js +1 -1
- lyte/lyte.js +33 -7
- lyte/lytesprite_claes.png +0 -0
- readme.txt +7 -2
- widget.php +39 -11
- wp-youtube-lyte.php +2 -2
lyte/lyte-min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(function(e){var t=document;var n="http";if(bU.indexOf("https")!=-1){n+="s"}e.te=function(){if(!
|
1 |
+
(function(e){var t=document;var n="http";if(bU.indexOf("https")!=-1){n+="s"}e.te=function(){if(!r){var r=1;var i=navigator.userAgent.match(/(iphone|ipad|ipod|android)/i);lts=e.getElementsByClassName("lyMe","div");for(var s=0,o=lts.length;s<o;s+=1){p=lts[s];vid=p.id.substring(4);if(i===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");if(thumb!==""){bgCss="#"+bgId+" { background-image: url("+thumb+"); }";e.addCss(bgCss)}else{scr=t.createElement("script");scr.src=n+"://gdata.youtube.com/feeds/api/playlists/"+vid+"?v=2&alt=json-in-script&callback=ly.parsePL&fields=id,entry";scr.type="text/javascript";t.getElementsByTagName("head")[0].appendChild(scr)}}p.onclick=e.play}else{e.play(p.id)}}}var r=""};e.parsePL=function(t){thumb=t.feed.entry[0].media$group.media$thumbnail[1].url;if(n=="https"&&thumb.indexOf("https"==-1)){thumb=thumb.replace("http://","https://")}t_id=t.feed.id.$t.match(/:playlist:(PL[a-zA-Z0-9_]+)/);id="lyte_"+t_id[1];bgCss="#"+id+" { background-image: url("+thumb+"); }";e.addCss(bgCss)};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&&aP==1){qsa+="&autohide=0";aHgh="438";aSt="position:relative;top:-400px;"}else if(tH.className.indexOf("audio")!==-1&&aP==0){tH.parentNode.style.height="";tH.style.height="";aHgh=tH.clientHeight;aSt="height:"+aHgh+"px !important;"}else{aHgh=tH.clientHeight;aSt=""}tH.innerHTML='<iframe id="iF_'+vid+'" width="'+tH.clientWidth+'px" height="'+aHgh+'px" src="'+eU+"autoplay="+aP+"&controls=1&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
@@ -21,9 +21,16 @@ ly.te = function() {
|
|
21 |
if (cN.indexOf('audio') === -1) {
|
22 |
bgId="lyte_"+vid;
|
23 |
thumb=d.getElementById(bgId).getAttribute("data-src");
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
p.onclick = ly.play;
|
28 |
} else {
|
29 |
ly.play(p.id);
|
@@ -33,6 +40,15 @@ ly.te = function() {
|
|
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");
|
@@ -63,14 +79,24 @@ ly.play = function(id) {
|
|
63 |
qsa=ly.getQ(tH);
|
64 |
|
65 |
if ((tH.className.indexOf("audio") !== -1) && (aP == 1)) {
|
66 |
-
|
67 |
} else if ((tH.className.indexOf("audio") !== -1) && (aP == 0)) {
|
68 |
-
|
|
|
|
|
|
|
69 |
} else {
|
70 |
-
|
71 |
}
|
|
|
|
|
|
|
|
|
|
|
72 |
|
73 |
-
|
|
|
|
|
74 |
|
75 |
if(typeof tH.firstChild.getAttribute('kabl')=="string") tH.innerHTML="Please check Karma Blocker's config.";
|
76 |
}
|
21 |
if (cN.indexOf('audio') === -1) {
|
22 |
bgId="lyte_"+vid;
|
23 |
thumb=d.getElementById(bgId).getAttribute("data-src");
|
24 |
+
if (thumb !== "") {
|
25 |
+
bgCss="#"+bgId+" { background-image: url("+thumb+"); }";
|
26 |
+
ly.addCss(bgCss);
|
27 |
+
} else {
|
28 |
+
scr = d.createElement('script');
|
29 |
+
scr.src = sch+"://gdata.youtube.com/feeds/api/playlists/"+ vid +"?v=2&alt=json-in-script&callback=ly.parsePL&fields=id,entry";
|
30 |
+
scr.type = "text/javascript";
|
31 |
+
d.getElementsByTagName('head')[0].appendChild(scr);
|
32 |
+
}
|
33 |
+
}
|
34 |
p.onclick = ly.play;
|
35 |
} else {
|
36 |
ly.play(p.id);
|
40 |
var rn="";
|
41 |
}
|
42 |
|
43 |
+
ly.parsePL = function(r) {
|
44 |
+
thumb=r.feed.entry[0].media$group.media$thumbnail[1].url;
|
45 |
+
if ((sch=="https")&&(thumb.indexOf('https'==-1))) {thumb=thumb.replace("http://","https://");}
|
46 |
+
t_id=r.feed.id.$t.match(/:playlist:(PL[a-zA-Z0-9_]+)/);
|
47 |
+
id="lyte_"+t_id[1];
|
48 |
+
bgCss="#"+id+" { background-image: url("+thumb+"); }";
|
49 |
+
ly.addCss(bgCss);
|
50 |
+
}
|
51 |
+
|
52 |
ly.getQ = function(nD) {
|
53 |
qsa="";
|
54 |
if (rqs=nD.className.match(/qsa_(.*)\s/,"$1")) qsa=rqs[1].replace(/\\([\&\=\?])/g, "$1");
|
79 |
qsa=ly.getQ(tH);
|
80 |
|
81 |
if ((tH.className.indexOf("audio") !== -1) && (aP == 1)) {
|
82 |
+
qsa+="&autohide=0";aHgh="438";aSt="position:relative;top:-400px;"
|
83 |
} else if ((tH.className.indexOf("audio") !== -1) && (aP == 0)) {
|
84 |
+
tH.parentNode.style.height="";
|
85 |
+
tH.style.height="";
|
86 |
+
aHgh=tH.clientHeight;
|
87 |
+
aSt="height:"+aHgh+"px !important;";
|
88 |
} else {
|
89 |
+
aHgh=tH.clientHeight;aSt="";
|
90 |
}
|
91 |
+
|
92 |
+
tH.innerHTML="<iframe id=\"iF_" + vid + "\" width=\"" + tH.clientWidth + "px\" height=\"" + aHgh + "px\" src=\""+eU+"autoplay="+aP+"&controls=1&wmode=opaque&rel=0&egm=0&iv_load_policy=3&hd="+hidef+qsa+"\" frameborder=\"0\" style=\"" + aSt + "\" allowfullscreen></iframe>"
|
93 |
+
|
94 |
+
/*
|
95 |
+
ytUrl=eU+"autoplay="+aP+"&wmode=opaque&rel=0&egm=0&iv_load_policy=3&hd="+hidef+qsa;
|
96 |
|
97 |
+
lytePop=window.open(ytUrl,'name','height='+aHgh+',width='+tH.clientWidth);
|
98 |
+
if (window.focus) {lytePop.focus()}
|
99 |
+
*/
|
100 |
|
101 |
if(typeof tH.firstChild.getAttribute('kabl')=="string") tH.innerHTML="Please check Karma Blocker's config.";
|
102 |
}
|
lyte/lytesprite_claes.png
ADDED
Binary file
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== WP YouTube Lyte ===
|
2 |
Contributors: futtta
|
3 |
-
Tags: youtube, video, lyte, lite youtube embeds, html5 video,
|
4 |
Requires at least: 2.9
|
5 |
Tested up to: 3.6
|
6 |
-
Stable tag: 1.3.
|
7 |
|
8 |
High performance YouTube video, playlist and audio-only embeds which don't slow down your blog and offer optimal accessibility.
|
9 |
|
@@ -105,6 +105,11 @@ Just tell me, I like the feedback! Use the [Contact-page on my blog](http://blog
|
|
105 |
|
106 |
== Changelog ==
|
107 |
|
|
|
|
|
|
|
|
|
|
|
108 |
= 1.3.1 =
|
109 |
* Workaround for broken audio-only on mobile (due to YouTube not showing bottom controls when iOS or Android is detected) as reported by [stevygee1987](http://wordpress.org/support/topic/audio-embed-is-a-black-bar-on-iphone). Result; audio-only YouTube becomes a normal YouTube video on mobile [until a better solution can be found](http://stackoverflow.com/questions/18273658/embedded-yt-on-mobile-autohide-0controls-1-but-controls-invisible).
|
110 |
* Added extra check to prevent plugin-files being called outside of WordPress [as suggested in this good article on security](http://mikejolley.com/2013/08/keeping-your-shit-secure-whilst-developing-for-wordpress/).
|
1 |
=== WP YouTube Lyte ===
|
2 |
Contributors: futtta
|
3 |
+
Tags: youtube, video, lyte, lite youtube embeds, html5 video, widget, youtube audio, audio, playlist, performance, accessibility, sidebar, lazy load, responsive, microdata, videoobject
|
4 |
Requires at least: 2.9
|
5 |
Tested up to: 3.6
|
6 |
+
Stable tag: 1.3.2
|
7 |
|
8 |
High performance YouTube video, playlist and audio-only embeds which don't slow down your blog and offer optimal accessibility.
|
9 |
|
105 |
|
106 |
== Changelog ==
|
107 |
|
108 |
+
= 1.3.2 =
|
109 |
+
* Added playlist support in the WP YouTube Lyte widget (forget to add it really, thanks to [Ed Dingwall](http://www.sinthomedia.com/) to remind me)
|
110 |
+
* Added an alternative lytesprite version, created by [Claes from PCPLAY.se](http://pcplay.se/). To switch, rename lyte/lytesprite.png to lyte/lytesprite_orig.png and then rename lyte/lytesprite_claes.png to lyte/lytesprite.png.
|
111 |
+
* Fixed some PHP notices in widget.php
|
112 |
+
|
113 |
= 1.3.1 =
|
114 |
* Workaround for broken audio-only on mobile (due to YouTube not showing bottom controls when iOS or Android is detected) as reported by [stevygee1987](http://wordpress.org/support/topic/audio-embed-is-a-black-bar-on-iphone). Result; audio-only YouTube becomes a normal YouTube video on mobile [until a better solution can be found](http://stackoverflow.com/questions/18273658/embedded-yt-on-mobile-autohide-0controls-1-but-controls-invisible).
|
115 |
* Added extra check to prevent plugin-files being called outside of WordPress [as suggested in this good article on security](http://mikejolley.com/2013/08/keeping-your-shit-secure-whilst-developing-for-wordpress/).
|
widget.php
CHANGED
@@ -1,6 +1,4 @@
|
|
1 |
<?php
|
2 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
3 |
-
|
4 |
class WYLWidget extends WP_Widget {
|
5 |
function WYLWidget() {
|
6 |
parent::WP_Widget(false, $name = 'WP YouTube Lyte');
|
@@ -28,7 +26,7 @@ class WYLWidget extends WP_Widget {
|
|
28 |
$wHeight = "38";
|
29 |
}
|
30 |
|
31 |
-
$WYLurl=str_replace("httpv://","http://"
|
32 |
|
33 |
$WYLqs=substr(strstr($WYLurl,'?'),1);
|
34 |
parse_str($WYLqs,$WYLarr);
|
@@ -36,7 +34,15 @@ class WYLWidget extends WP_Widget {
|
|
36 |
if (strpos($WYLurl,'youtu.be')) {
|
37 |
$WYLid=substr(parse_url($WYLurl,PHP_URL_PATH),1,11);
|
38 |
} else {
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
}
|
41 |
|
42 |
if (isset($WYLarr['start'])) $qsa="&start=".$WYLarr['start'];
|
@@ -54,13 +60,12 @@ class WYLWidget extends WP_Widget {
|
|
54 |
}
|
55 |
|
56 |
$WYL_dom_id="YLW_".$WYLid;
|
57 |
-
$WYLthumb="http://img.youtube.com/vi/".$WYLid."/mqdefault.jpg";
|
58 |
|
59 |
$lyteSettings['path']=$wp_lyte_plugin_url."lyte/";
|
60 |
?>
|
61 |
<?php echo $before_widget; ?>
|
62 |
<?php if ( $WYLtitle ) echo $before_title . $WYLtitle . $after_title; ?>
|
63 |
-
<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 $audioClass; 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>
|
64 |
<div><?php echo $WYLtext ?></div>
|
65 |
<?php echo $after_widget; ?>
|
66 |
<?php
|
@@ -86,14 +91,37 @@ class WYLWidget extends WP_Widget {
|
|
86 |
function form($instance) {
|
87 |
global $wSize, $wDefault;
|
88 |
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
|
93 |
-
|
|
|
|
|
|
|
|
|
94 |
if ($WYLaudio!=="audio") $WYLaudio="";
|
95 |
|
96 |
-
|
|
|
|
|
|
|
|
|
|
|
97 |
if ($WYLsize=="") $WYLsize=$wDefault;
|
98 |
|
99 |
?>
|
1 |
<?php
|
|
|
|
|
2 |
class WYLWidget extends WP_Widget {
|
3 |
function WYLWidget() {
|
4 |
parent::WP_Widget(false, $name = 'WP YouTube Lyte');
|
26 |
$wHeight = "38";
|
27 |
}
|
28 |
|
29 |
+
$WYLurl=str_replace("httpv://","http://",trim($instance['WYLurl']));
|
30 |
|
31 |
$WYLqs=substr(strstr($WYLurl,'?'),1);
|
32 |
parse_str($WYLqs,$WYLarr);
|
34 |
if (strpos($WYLurl,'youtu.be')) {
|
35 |
$WYLid=substr(parse_url($WYLurl,PHP_URL_PATH),1,11);
|
36 |
} else {
|
37 |
+
if (isset($WYLarr['v'])) {
|
38 |
+
$WYLid=$WYLarr['v'];
|
39 |
+
$PLClass="";
|
40 |
+
$WYLthumb="http://img.youtube.com/vi/".$WYLid."/mqdefault.jpg";
|
41 |
+
} else if (isset($WYLarr['list'])) {
|
42 |
+
$WYLid=$WYLarr['list'];
|
43 |
+
$PLClass=" playlist";
|
44 |
+
$WYLthumb="";
|
45 |
+
}
|
46 |
}
|
47 |
|
48 |
if (isset($WYLarr['start'])) $qsa="&start=".$WYLarr['start'];
|
60 |
}
|
61 |
|
62 |
$WYL_dom_id="YLW_".$WYLid;
|
|
|
63 |
|
64 |
$lyteSettings['path']=$wp_lyte_plugin_url."lyte/";
|
65 |
?>
|
66 |
<?php echo $before_widget; ?>
|
67 |
<?php if ( $WYLtitle ) echo $before_title . $WYLtitle . $after_title; ?>
|
68 |
+
<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 $PLClass; echo $audioClass; 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>
|
69 |
<div><?php echo $WYLtext ?></div>
|
70 |
<?php echo $after_widget; ?>
|
71 |
<?php
|
91 |
function form($instance) {
|
92 |
global $wSize, $wDefault;
|
93 |
|
94 |
+
if (isset($instance['WYLtitle'])) {
|
95 |
+
$WYLtitle = esc_attr($instance['WYLtitle']);
|
96 |
+
} else {
|
97 |
+
$WYLtitle = "";
|
98 |
+
}
|
99 |
+
|
100 |
+
if (isset($instance['WYLurl'])) {
|
101 |
+
$WYLurl = esc_attr($instance['WYLurl']);
|
102 |
+
} else {
|
103 |
+
$WYLurl = "";
|
104 |
+
}
|
105 |
+
|
106 |
+
if (isset($instance['WYLtext'])) {
|
107 |
+
$WYLtext = format_to_edit($instance['WYLtext']);
|
108 |
+
} else {
|
109 |
+
$WYLtext = "";
|
110 |
+
}
|
111 |
|
112 |
+
if (isset($instance['WYLaudio'])) {
|
113 |
+
$WYLaudio = esc_attr($instance['WYLaudio']);
|
114 |
+
} else {
|
115 |
+
$WYLaudio = "";
|
116 |
+
}
|
117 |
if ($WYLaudio!=="audio") $WYLaudio="";
|
118 |
|
119 |
+
if (isset($instance['WYLsize'])) {
|
120 |
+
$WYLsize = esc_attr($instance['WYLsize']);
|
121 |
+
} else {
|
122 |
+
$WYLsize = "";
|
123 |
+
}
|
124 |
+
|
125 |
if ($WYLsize=="") $WYLsize=$wDefault;
|
126 |
|
127 |
?>
|
wp-youtube-lyte.php
CHANGED
@@ -4,7 +4,7 @@ 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.3.
|
8 |
Author URI: http://blog.futtta.be/
|
9 |
Text Domain: wp-youtube-lyte
|
10 |
Domain Path: /languages
|
@@ -13,7 +13,7 @@ Domain Path: /languages
|
|
13 |
if ( ! defined( 'ABSPATH' ) ) exit;
|
14 |
|
15 |
$debug=false;
|
16 |
-
$lyte_version="1.3.
|
17 |
$lyte_db_version=get_option('lyte_version','none');
|
18 |
|
19 |
/** have we updated? */
|
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.3.2
|
8 |
Author URI: http://blog.futtta.be/
|
9 |
Text Domain: wp-youtube-lyte
|
10 |
Domain Path: /languages
|
13 |
if ( ! defined( 'ABSPATH' ) ) exit;
|
14 |
|
15 |
$debug=false;
|
16 |
+
$lyte_version="1.3.2";
|
17 |
$lyte_db_version=get_option('lyte_version','none');
|
18 |
|
19 |
/** have we updated? */
|