WP YouTube Lyte - Version 1.7.9

Version Description

  • improved AMP checking (LYTE should never be active on AMP pages)
  • improvements to gutenberg block parsing
  • switch filter priority to 10 instead of 4 to allow "catching" more rendered YouTube videos
  • fix jsapi breakeage
  • misc. smaller changes/ fixes
Download this release

Release Info

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

Code changes from version 1.7.8 to 1.7.9

Files changed (5) hide show
  1. index.html +1 -1
  2. lyte/index.html +1 -1
  3. readme.txt +9 -2
  4. widget.php +1 -1
  5. wp-youtube-lyte.php +15 -10
index.html CHANGED
@@ -1 +1 @@
1
- <html><body><p><a href="http://wordpress.org/extend/plugins/wp-youtube-lyte/">WP-YouTube-Lyte</a> is a WordPress plugin that inserts "Lite YouTube Embeds" in your blog. These look and feel like normal embedded YouTube, but don't use Flash unless clicked on, thereby <a href="http://blog.futtta.be/2010/04/23/high-performance-youtube-embeds/" title="performance tests comparing youtube embeds with lyte embeds">reducing download size & rendering time substantially</a>. The plugin can optionally use <a href="http://apiblog.youtube.com/2010/07/new-way-to-embed-youtube-videos.html">YouTube's new experimental HTML5 embed code</a>, meaning you can have an entirely flash-less YouTube experience on your blog.</p><p>Up to date info on WP-YouTube-Lyte <a href="http://blog.futtta.be/tag/lyte/" title="more about Lyte on my blog">can be found on blog.futtta.be</a>, where you can also find <a href="http://blog.futtta.be/tag/wordpress" title="blog.futtta.be about WordPress">posts about WordPress</a> and <a href="http://blog.futtta.be/category/internet/" title="about browsers, development and mobile web on blog.futtta.be">Web Technology in general</a>.</p></body></html>
1
+ <html><head><meta name="robots" content="noindex, nofollow"></head><body><p><a href="http://wordpress.org/extend/plugins/wp-youtube-lyte/">WP-YouTube-Lyte</a> is a WordPress plugin that inserts "Lite YouTube Embeds" in your blog. These look and feel like normal embedded YouTube, but don't use Flash unless clicked on, thereby <a href="http://blog.futtta.be/2010/04/23/high-performance-youtube-embeds/" title="performance tests comparing youtube embeds with lyte embeds">reducing download size & rendering time substantially</a>. The plugin can optionally use <a href="http://apiblog.youtube.com/2010/07/new-way-to-embed-youtube-videos.html">YouTube's new experimental HTML5 embed code</a>, meaning you can have an entirely flash-less YouTube experience on your blog.</p><p>Up to date info on WP-YouTube-Lyte <a href="http://blog.futtta.be/tag/lyte/" title="more about Lyte on my blog">can be found on blog.futtta.be</a>, where you can also find <a href="http://blog.futtta.be/tag/wordpress" title="blog.futtta.be about WordPress">posts about WordPress</a> and <a href="http://blog.futtta.be/category/internet/" title="about browsers, development and mobile web on blog.futtta.be">Web Technology in general</a>.</p></body></html>
lyte/index.html CHANGED
@@ -1 +1 @@
1
- <html><body><p><a href="http://wordpress.org/extend/plugins/wp-youtube-lyte/">WP-YouTube-Lyte</a> is a WordPress plugin that inserts "Lite YouTube Embeds" in your blog. These look and feel like normal embedded YouTube, but don't use Flash unless clicked on, thereby <a href="http://blog.futtta.be/2010/04/23/high-performance-youtube-embeds/" title="performance tests comparing youtube embeds with lyte embeds">reducing download size & rendering time substantially</a>. The plugin can optionally use <a href="http://apiblog.youtube.com/2010/07/new-way-to-embed-youtube-videos.html">YouTube's new experimental HTML5 embed code</a>, meaning you can have an entirely flash-less YouTube experience on your blog.</p><p>Up to date info on WP-YouTube-Lyte <a href="http://blog.futtta.be/tag/lyte/" title="more about Lyte on my blog">can be found on blog.futtta.be</a>, where you can also find <a href="http://blog.futtta.be/tag/wordpress" title="blog.futtta.be about WordPress">posts about WordPress</a> and <a href="http://blog.futtta.be/category/internet/" title="about browsers, development and mobile web on blog.futtta.be">Web Technology in general</a>.</p></body></html>
1
+ <html><head><meta name="robots" content="noindex, nofollow"></head><body><p><a href="http://wordpress.org/extend/plugins/wp-youtube-lyte/">WP-YouTube-Lyte</a> is a WordPress plugin that inserts "Lite YouTube Embeds" in your blog. These look and feel like normal embedded YouTube, but don't use Flash unless clicked on, thereby <a href="http://blog.futtta.be/2010/04/23/high-performance-youtube-embeds/" title="performance tests comparing youtube embeds with lyte embeds">reducing download size & rendering time substantially</a>. The plugin can optionally use <a href="http://apiblog.youtube.com/2010/07/new-way-to-embed-youtube-videos.html">YouTube's new experimental HTML5 embed code</a>, meaning you can have an entirely flash-less YouTube experience on your blog.</p><p>Up to date info on WP-YouTube-Lyte <a href="http://blog.futtta.be/tag/lyte/" title="more about Lyte on my blog">can be found on blog.futtta.be</a>, where you can also find <a href="http://blog.futtta.be/tag/wordpress" title="blog.futtta.be about WordPress">posts about WordPress</a> and <a href="http://blog.futtta.be/category/internet/" title="about browsers, development and mobile web on blog.futtta.be">Web Technology in general</a>.</p></body></html>
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: youtube, video, performance, gdpr, lazy load
4
  Donate link: http://blog.futtta.be/2013/10/21/do-not-donate-to-me/
5
  Requires at least: 4.0
6
  Tested up to: 5.3
7
- Stable tag: 1.7.8
8
 
9
  High performance YouTube video, playlist and audio-only embeds which don't slow down your blog and offer optimal accessibility.
10
 
@@ -135,13 +135,20 @@ Just tell me, I like the feedback! Use the [Contact-page on my blog](http://blog
135
 
136
  == Changelog ==
137
 
 
 
 
 
 
 
 
138
  = 1.7.8 =
139
  * misc. improvements to prevent structured data warnings from Google.
140
  * fix breaking locally cached thumbnails when mime_content_type function is not available.
141
  * tested with WordPress 5.3 (beta 3).
142
 
143
  = 1.7.7 =
144
- * bugfix: avoid having to click play twice in Chrome (due to autoplay not working).
145
 
146
  = 1.7.6 =
147
  * improvement: extra parameters for shortcode (start, showinfo, stepsize and hqthumb).
4
  Donate link: http://blog.futtta.be/2013/10/21/do-not-donate-to-me/
5
  Requires at least: 4.0
6
  Tested up to: 5.3
7
+ Stable tag: 1.7.9
8
 
9
  High performance YouTube video, playlist and audio-only embeds which don't slow down your blog and offer optimal accessibility.
10
 
135
 
136
  == Changelog ==
137
 
138
+ = 1.7.9 =
139
+ * improved AMP checking (LYTE should never be active on AMP pages)
140
+ * improvements to gutenberg block parsing
141
+ * switch filter priority to 10 instead of 4 to allow "catching" more rendered YouTube videos
142
+ * fix jsapi breakeage
143
+ * misc. smaller changes/ fixes
144
+
145
  = 1.7.8 =
146
  * misc. improvements to prevent structured data warnings from Google.
147
  * fix breaking locally cached thumbnails when mime_content_type function is not available.
148
  * tested with WordPress 5.3 (beta 3).
149
 
150
  = 1.7.7 =
151
+ * bugfix: avoid having to click play twice in Chrome (due to autoplay not working)
152
 
153
  = 1.7.6 =
154
  * improvement: extra parameters for shortcode (start, showinfo, stepsize and hqthumb).
widget.php CHANGED
@@ -56,7 +56,7 @@ class WYLWidget extends WP_Widget {
56
  if (isset($WYLarr['start'])) $qsa="&amp;start=".$WYLarr['start'];
57
  if (isset($WYLarr['enablejsapi'])) {
58
  $urlArr=parse_url($lyteSettings['path']);
59
- $origin=$urlArr[scheme]."://".$urlArr[host]."/";
60
  $qsa.="&amp;enablejsapi=".$WYLarr['enablejsapi']."&amp;origin=".$origin;
61
  }
62
 
56
  if (isset($WYLarr['start'])) $qsa="&amp;start=".$WYLarr['start'];
57
  if (isset($WYLarr['enablejsapi'])) {
58
  $urlArr=parse_url($lyteSettings['path']);
59
+ $origin=$urlArr[scheme]."://".$urlArr[host];
60
  $qsa.="&amp;enablejsapi=".$WYLarr['enablejsapi']."&amp;origin=".$origin;
61
  }
62
 
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.7.8
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.7.8";
17
  $lyte_db_version=get_option('lyte_version','none');
18
 
19
  /** have we updated? */
@@ -91,7 +91,7 @@ function lyte_parse($the_content,$doExcerpt=false) {
91
  global $lyteSettings, $toCache_index, $postID, $cachekey;
92
  $lyteSettings['path']=plugins_url() . "/" . dirname(plugin_basename(__FILE__)) . '/lyte/';
93
  $urlArr=parse_url($lyteSettings['path']);
94
- $origin=$urlArr['scheme']."://".$urlArr['host']."/";
95
 
96
  /** API: filter hook to preparse the_content, e.g. to force normal youtube links to be parsed */
97
  $the_content = apply_filters( 'lyte_content_preparse',$the_content );
@@ -112,7 +112,7 @@ function lyte_parse($the_content,$doExcerpt=false) {
112
  }
113
  }
114
 
115
- if ( strpos($the_content,"<!-- wp:") !== false && strpos($the_content,"youtu") !== false ) {
116
  /*
117
  * do Gutenberg stuff here, playlists if needed first and then single videos
118
  *
@@ -123,10 +123,10 @@ function lyte_parse($the_content,$doExcerpt=false) {
123
  * https://media1.giphy.com/media/l2QZTNMFTQ2Z00zHG/giphy.gif
124
  */
125
  if (strpos($the_content,'/playlist?list=') !== false ) {
126
- $gutenbeard_playlist_regex = '%<\!--\s?wp:(?:core[-|/])?embed(?:/youtube)?\s?{"url":"https://www.youtube.com/playlist\?list=(.*)"}\s?-->.*<figcaption>(.*)</figcaption><\!--\s?/wp:(?:core[-|/])?embed(?:/youtube)?\s?-->%Us';
127
  $the_content = preg_replace($gutenbeard_playlist_regex, '<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube">httpv://www.youtube.com/playlist?list=\1<figcaption>\2</figcaption></figure>',$the_content);
128
  }
129
- $gutenbeard_single_regex = '%<\!--\s?wp:(?:core[-|/])?embed(?:/youtube)?\s?{"url":"https?://(?:www\.)?youtu(?:be\.com|.be)/(?:watch\?v=)?(.*)"}\s?-->.*<figcaption>(.*)</figcaption><\!--\s?/wp:(?:core[-|/])?embed(?:/youtube)?\s?-->%Us';
130
  $the_content = preg_replace($gutenbeard_single_regex, '<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube">httpv://www.youtube.com/watch?v=\1<figcaption>\2</figcaption></figure>',$the_content);
131
  }
132
 
@@ -208,7 +208,7 @@ function lyte_parse($the_content,$doExcerpt=false) {
208
  }
209
 
210
  if ($match[1]!=="a") {
211
- $divHeight=$lyteSettings[3];
212
  $audioClass="";
213
  $audio=false;
214
  } else {
@@ -248,6 +248,7 @@ function lyte_parse($the_content,$doExcerpt=false) {
248
  if (get_option('lyte_local_thumb','0') === '1') {
249
  $thumbUrl = plugins_url( 'lyteThumbs.php?origThumbUrl=' . urlencode($thumbUrl) , __FILE__ );
250
  }
 
251
  $noscript="<noscript><a href=\"".$lyteSettings['scheme']."://youtu.be/".$vid."\"><img src=\"" . $thumbUrl . "\" alt=\"\" width=\"".$lyteSettings[2]."\" height=\"".$NSimgHeight."\" />".$noscript_post."</a></noscript>";
252
  }
253
 
@@ -605,7 +606,7 @@ function lyte_initer() {
605
  /* actual initialization */
606
  function lyte_init() {
607
  global $lyteSettings;
608
- $lyte_css = ".lyte-wrapper-audio div, .lyte-wrapper div {margin:0px; overflow:hidden;} .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} .lyMe iframe, .lyte iframe,.lyte .pL{position:absolute !important;top:0;left:0;width:100%;height:100%!important;background:no-repeat scroll center #000;background-size:cover;cursor:pointer} .tC{left:0;position:absolute;top:0;width:100%} .tC{background-image:linear-gradient(to bottom,rgba(0,0,0,0.6),rgba(0,0,0,0))} .tT{color:#FFF;font-family:Roboto,sans-serif;font-size:16px;height:auto;text-align:left;padding:5px 10px 50px 10px} .play{background:no-repeat scroll 0 0 transparent;width:88px;height:63px;position:absolute;left:43%;left:calc(50% - 44px);left:-webkit-calc(50% - 44px);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;} .lyte-audio .pL{max-height:38px!important} .lyte-audio iframe{height:438px!important} .ctrl{background:repeat scroll 0 -220px rgba(0,0,0,0.3);width:100%;height:40px;bottom:0px;left:0;position:absolute;} .lyte-wrapper .ctrl{display:none}.Lctrl{background:no-repeat scroll 0 -137px transparent;width:158px;height:40px;bottom:0;left:0;position:absolute} .Rctrl{background:no-repeat scroll -42px -179px transparent;width:117px;height:40px;bottom:0;right:0;position:absolute;padding-right:10px;}.lyte-audio .play{display:none}.lyte-audio .ctrl{background-color:rgba(0,0,0,1)}.hidden{display:none}";
609
 
610
  // by default show lyte vid on mobile (requiring user clicking play two times)
611
  // but can be overruled by this filter
@@ -735,7 +736,11 @@ function lyte_add_action_link($links) {
735
  /** is_amp, but I shouldn't have to do this, should I? */
736
  if (!function_exists("is_amp")) {
737
  function is_amp() {
738
- if ((strpos($_SERVER['REQUEST_URI'],'?amp')!==false) || (strpos($_SERVER['REQUEST_URI'],'/amp/')!==false)) {
 
 
 
 
739
  return true;
740
  } else {
741
  return false;
@@ -748,7 +753,7 @@ if ( is_admin() ) {
748
  require_once(dirname(__FILE__).'/options.php');
749
  add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'lyte_add_action_link' );
750
  } else {
751
- add_filter('the_content', 'lyte_parse', 4);
752
  add_shortcode("lyte", "shortcode_lyte");
753
  remove_filter('get_the_excerpt', 'wp_trim_excerpt');
754
  add_filter('get_the_excerpt', 'lyte_trim_excerpt');
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.7.9
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.7.9";
17
  $lyte_db_version=get_option('lyte_version','none');
18
 
19
  /** have we updated? */
91
  global $lyteSettings, $toCache_index, $postID, $cachekey;
92
  $lyteSettings['path']=plugins_url() . "/" . dirname(plugin_basename(__FILE__)) . '/lyte/';
93
  $urlArr=parse_url($lyteSettings['path']);
94
+ $origin=$urlArr['scheme']."://".$urlArr['host'];
95
 
96
  /** API: filter hook to preparse the_content, e.g. to force normal youtube links to be parsed */
97
  $the_content = apply_filters( 'lyte_content_preparse',$the_content );
112
  }
113
  }
114
 
115
+ if ( strpos($the_content,"<!-- wp:") !== false && strpos($the_content,"youtu") !== false && apply_filters( 'lyte_filter_do_gutenberg', '__return_true' ) ) {
116
  /*
117
  * do Gutenberg stuff here, playlists if needed first and then single videos
118
  *
123
  * https://media1.giphy.com/media/l2QZTNMFTQ2Z00zHG/giphy.gif
124
  */
125
  if (strpos($the_content,'/playlist?list=') !== false ) {
126
+ $gutenbeard_playlist_regex = '%<\!--\s?wp:(?:core[-|/])?embed(?:/youtube)?\s?{"url":"https://www.youtube.com/playlist\?list=(.*)"(?:.*)?}\s?-->.*(?:<figcaption>(.*)</figcaption>)?<\!--\s?/wp:(?:core[-|/])?embed(?:/youtube)?\s?-->%Us';
127
  $the_content = preg_replace($gutenbeard_playlist_regex, '<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube">httpv://www.youtube.com/playlist?list=\1<figcaption>\2</figcaption></figure>',$the_content);
128
  }
129
+ $gutenbeard_single_regex = '%<\!--\s?wp:(?:core[-|/])?embed(?:/youtube)?\s?{"url":"https?://(?:www\.)?youtu(?:be\.com/watch\?v=|.be/)(.*)"(?:.*)?}\s?-->.*(?:<figcaption>(.*)</figcaption>)?<\!--\s?/wp:(?:core[-|/])?embed(?:/youtube)?\s?-->%Us';
130
  $the_content = preg_replace($gutenbeard_single_regex, '<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube">httpv://www.youtube.com/watch?v=\1<figcaption>\2</figcaption></figure>',$the_content);
131
  }
132
 
208
  }
209
 
210
  if ($match[1]!=="a") {
211
+ $divHeight=$lyteSettings[3];
212
  $audioClass="";
213
  $audio=false;
214
  } else {
248
  if (get_option('lyte_local_thumb','0') === '1') {
249
  $thumbUrl = plugins_url( 'lyteThumbs.php?origThumbUrl=' . urlencode($thumbUrl) , __FILE__ );
250
  }
251
+ $thumbUrl = apply_filters( 'lyte_match_thumburl', $thumbUrl, $vid );
252
  $noscript="<noscript><a href=\"".$lyteSettings['scheme']."://youtu.be/".$vid."\"><img src=\"" . $thumbUrl . "\" alt=\"\" width=\"".$lyteSettings[2]."\" height=\"".$NSimgHeight."\" />".$noscript_post."</a></noscript>";
253
  }
254
 
606
  /* actual initialization */
607
  function lyte_init() {
608
  global $lyteSettings;
609
+ $lyte_css = ".lyte-wrapper-audio div, .lyte-wrapper div {margin:0px; overflow:hidden;} .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} .lyMe iframe, .lyte iframe,.lyte .pL{position:absolute !important;top:0;left:0;width:100%;height:100%!important;background:no-repeat scroll center #000;background-size:cover;cursor:pointer} .tC{left:0;position:absolute;top:0;width:100%} .tC{background-image:linear-gradient(to bottom,rgba(0,0,0,0.6),rgba(0,0,0,0))} .tT{color:#FFF;font-family:Roboto,sans-serif;font-size:16px;height:auto;text-align:left;padding:5px 10px 50px 10px} .play{background:no-repeat scroll 0 0 transparent;width:88px;height:63px;position:absolute;left:43%;left:calc(50% - 44px);left:-webkit-calc(50% - 44px);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;} .lyte-audio .pL{max-height:38px!important} .lyte-audio iframe{height:438px!important} .ctrl{background:repeat scroll 0 -220px rgba(0,0,0,0.3);width:100%;height:40px;bottom:0px;left:0;position:absolute;} .lyte-wrapper .ctrl{display:none}.Lctrl{background:no-repeat scroll 0 -137px transparent;width:158px;height:40px;bottom:0;left:0;position:absolute} .Rctrl{background:no-repeat scroll -42px -179px transparent;width:117px;height:40px;bottom:0;right:0;position:absolute;padding-right:10px;}.lyte-audio .play{display:none}.lyte-audio .ctrl{background-color:rgba(0,0,0,1)}.lyte .hidden{display:none}";
610
 
611
  // by default show lyte vid on mobile (requiring user clicking play two times)
612
  // but can be overruled by this filter
736
  /** is_amp, but I shouldn't have to do this, should I? */
737
  if (!function_exists("is_amp")) {
738
  function is_amp() {
739
+ if ( function_exists('is_amp_endpoint') ) {
740
+ return is_amp_endpoint();
741
+ } else if ( function_exists('ampforwp_is_amp_endpoint') ) {
742
+ return ampforwp_is_amp_endpoint();
743
+ } else if ((strpos($_SERVER['REQUEST_URI'],'?amp')!==false) || (strpos($_SERVER['REQUEST_URI'],'/amp/')!==false)) {
744
  return true;
745
  } else {
746
  return false;
753
  require_once(dirname(__FILE__).'/options.php');
754
  add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'lyte_add_action_link' );
755
  } else {
756
+ add_filter('the_content', 'lyte_parse', 10);
757
  add_shortcode("lyte", "shortcode_lyte");
758
  remove_filter('get_the_excerpt', 'wp_trim_excerpt');
759
  add_filter('get_the_excerpt', 'lyte_trim_excerpt');