WP YouTube Lyte - Version 1.7.20

Version Description

  • misc. parsing improvements, resulting in YT shorts working as well.
Download this release

Release Info

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

Code changes from version 1.7.19 to 1.7.20

Files changed (2) hide show
  1. readme.txt +5 -2
  2. wp-youtube-lyte.php +17 -11
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: futtta, optimizingmatters
3
  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: 6.0
7
- Stable tag: 1.7.19
8
 
9
  High performance YouTube video, playlist and audio-only embeds which don't slow down your blog and offer optimal accessibility.
10
 
@@ -143,6 +143,9 @@ Just tell me, I like the feedback! Use the [Contact-page on my blog](http://blog
143
 
144
  == Changelog ==
145
 
 
 
 
146
  = 1.7.19 =
147
  * improvements to the alternative lazyload feature (kudos to Stirius & believableUN and softromano for helping/ testing!)
148
  * lyteCache: if maxresdefault.jpg does not exist, try hqdefault.jpg instead (contribution of R33D3M33R, thanks!)
3
  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: 6.0
7
+ Stable tag: 1.7.20
8
 
9
  High performance YouTube video, playlist and audio-only embeds which don't slow down your blog and offer optimal accessibility.
10
 
143
 
144
  == Changelog ==
145
 
146
+ = 1.7.20 =
147
+ * misc. parsing improvements, resulting in YT shorts working as well.
148
+
149
  = 1.7.19 =
150
  * improvements to the alternative lazyload feature (kudos to Stirius & believableUN and softromano for helping/ testing!)
151
  * lyteCache: if maxresdefault.jpg does not exist, try hqdefault.jpg instead (contribution of R33D3M33R, thanks!)
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.19
8
  Author URI: http://blog.futtta.be/
9
  Text Domain: wp-youtube-lyte
10
  */
@@ -14,7 +14,7 @@ Text Domain: wp-youtube-lyte
14
  if ( ! defined( 'ABSPATH' ) ) exit;
15
 
16
  $debug = false;
17
- $lyte_version = '1.7.19';
18
  $lyte_db_version = get_option( 'lyte_version', 'none' );
19
 
20
  /** have we updated? */
@@ -234,7 +234,7 @@ function lyte_parse( $the_content, $doExcerpt = false ) {
234
  switch ( $lyteSettings['links'] ) {
235
  case '0':
236
  $noscript_post = '<br />' . __( 'Watch this playlist on YouTube', 'wp-youtube-lyte' );
237
- $noscript = '<noscript><a href="' . $lyteSettings['scheme'] . '://youtube.com/playlist?list=' . $vid . '">' . $noscript_post . '</a></noscript>';
238
  $lytelinks_txt = '';
239
  break;
240
  default:
@@ -258,7 +258,7 @@ function lyte_parse( $the_content, $doExcerpt = false ) {
258
  $thumbUrl = plugins_url( 'lyteCache.php?origThumbUrl=' . urlencode($thumbUrl) , __FILE__ );
259
  }
260
  $thumbUrl = apply_filters( 'lyte_match_thumburl', $thumbUrl, $vid );
261
- $noscript = '<noscript><a href="' . $lyteSettings['scheme'] . '://youtu.be/' . $vid . '"><img src="' . $thumbUrl . '" alt="" width="' . $lyteSettings[2] . '" height="' . $NSimgHeight . '" />' . $noscript_post . '</a></noscript>';
262
  }
263
 
264
  // add disclaimer to lytelinks
@@ -578,7 +578,7 @@ function lyte_initer() {
578
  /* actual initialization */
579
  function lyte_init( $echo = true ) {
580
  global $lyteSettings;
581
- $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}';
582
 
583
  // by default show lyte vid on mobile (requiring user clicking play two times)
584
  // but can be overruled by this filter
@@ -786,13 +786,19 @@ function lyte_prepare( $the_content ) {
786
 
787
  // do the most of the greedy part early.
788
  if ( get_option( 'lyte_greedy', '1' ) === '1' && strpos( $the_content, 'youtu' ) !== false ) {
789
- // only preg_replace if "youtu" (as part of youtube.com or youtu.be) is found.
790
- if ( strpos( $the_content, '/playlist?list=' ) !== false ) {
791
- // only preg_replace for playlists if there are playlists to be parsed.
792
- $the_content = preg_replace( '/^(?:<p>)?https?:\/\/(www.)?youtu(be.com|.be)\/playlist\?list=/m', 'httpv://www.youtube.com/playlist?list=', $the_content );
 
 
 
 
 
 
 
 
793
  }
794
- // and lastly normal single embeds.
795
- $the_content = preg_replace( '/^(?:<p>)?https?:\/\/(www.)?youtu(be.com|.be)\/(watch\?v=)?/m', 'httpv://www.youtube.com/watch?v=', $the_content );
796
  }
797
  return $the_content;
798
  }
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.20
8
  Author URI: http://blog.futtta.be/
9
  Text Domain: wp-youtube-lyte
10
  */
14
  if ( ! defined( 'ABSPATH' ) ) exit;
15
 
16
  $debug = false;
17
+ $lyte_version = '1.7.20';
18
  $lyte_db_version = get_option( 'lyte_version', 'none' );
19
 
20
  /** have we updated? */
234
  switch ( $lyteSettings['links'] ) {
235
  case '0':
236
  $noscript_post = '<br />' . __( 'Watch this playlist on YouTube', 'wp-youtube-lyte' );
237
+ $noscript = '<noscript><a href="' . $lyteSettings['scheme'] . '://youtube.com/playlist?list=' . $vid . '" rel="nofollow">' . $noscript_post . '</a></noscript>';
238
  $lytelinks_txt = '';
239
  break;
240
  default:
258
  $thumbUrl = plugins_url( 'lyteCache.php?origThumbUrl=' . urlencode($thumbUrl) , __FILE__ );
259
  }
260
  $thumbUrl = apply_filters( 'lyte_match_thumburl', $thumbUrl, $vid );
261
+ $noscript = '<noscript><a href="' . $lyteSettings['scheme'] . '://youtu.be/' . $vid . '" rel="nofollow"><img src="' . $thumbUrl . '" alt="" width="' . $lyteSettings[2] . '" height="' . $NSimgHeight . '" />' . $noscript_post . '</a></noscript>';
262
  }
263
 
264
  // add disclaimer to lytelinks
578
  /* actual initialization */
579
  function lyte_init( $echo = true ) {
580
  global $lyteSettings;
581
+ $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} .lyte .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}';
582
 
583
  // by default show lyte vid on mobile (requiring user clicking play two times)
584
  // but can be overruled by this filter
786
 
787
  // do the most of the greedy part early.
788
  if ( get_option( 'lyte_greedy', '1' ) === '1' && strpos( $the_content, 'youtu' ) !== false ) {
789
+ $prep_replas = array();
790
+ $prep_replas['list'] = array( 'tell' => '/playlist?list=', 'regex' => '#^((?:<p>)?https?:\/\/(?:www.)?youtu(?:be.com|.be)\/(?:playlist\?list=))?.*$#m', 'replace' => 'httpv://www.youtube.com/playlist?list=' );
791
+ $prep_replas['vid'] = array( 'tell' => '/watch?v=', 'regex' => '#^((?:<p>)?https?:\/\/(?:www.)?youtu(?:be.com|.be)\/(?:watch\?v=))?.*$#m', 'replace' => 'httpv://www.youtube.com/watch?v=' );
792
+
793
+ foreach ( $prep_replas as $prep_repla ) {
794
+ if ( false !== strpos( $the_content, $prep_repla['tell'] ) && preg_match_all( $prep_repla['regex'], $the_content, $vids, PREG_SET_ORDER ) ) {
795
+ foreach ( $vids as $vid ) {
796
+ if ( is_array( $vid ) && array_key_exists( 1, $vid ) && false === strpos( trim( $vid[0] ), ' ' ) ) {
797
+ $the_content = str_replace( $vid[1], $prep_repla['replace'], $the_content );
798
+ }
799
+ }
800
+ }
801
  }
 
 
802
  }
803
  return $the_content;
804
  }