WP YouTube Lyte - Version 1.7.2

Version Description

  • new: you can add a text underneath each video (e.g. for privacy disclaimer purposes, think GDPR) by adding it on the settings-page
  • fix: thumbnails from LYTE without API key can now also be cached locally
Download this release

Release Info

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

Code changes from version 1.7.1 to 1.7.2

Files changed (4) hide show
  1. lyteThumbs.php +6 -2
  2. options.php +27 -15
  3. readme.txt +9 -5
  4. wp-youtube-lyte.php +15 -5
lyteThumbs.php CHANGED
@@ -74,6 +74,10 @@ if ( lyte_check_cache_dir(LYTE_CACHE_DIR) === false ) {
74
  * step 3: if not in cache: fetch from YT and store in cache
75
  */
76
 
 
 
 
 
77
  $localThumb = LYTE_CACHE_DIR . '/' . md5($origThumbURL) . ".jpg";
78
 
79
  if ( !file_exists($localThumb) || $lyte_thumb_dontsave ) {
@@ -157,7 +161,7 @@ function lyte_get_thumb($thumbUrl) {
157
  if ( !$err && $str != "" ) {
158
  return $str;
159
  } else {
160
- $lyte_thumb_error .= "curl err/ ";
161
  }
162
  } else {
163
  $lyte_thumb_error .= "no curl/ ";
@@ -169,7 +173,7 @@ function lyte_get_thumb($thumbUrl) {
169
  }
170
 
171
  function lyte_thumb_fallback() {
172
- global $origThumbURL, $lyte_thumb_error;
173
  // if for any reason we can't show a local thumbnail, we redirect to the original one
174
  if ( strpos( $origThumbURL, "http" ) !== 0) {
175
  $origThumbURL = "https:".$origThumbURL;
74
  * step 3: if not in cache: fetch from YT and store in cache
75
  */
76
 
77
+ if ( strpos($origThumbURL,'http') !== 0 && strpos($origThumbURL,'//') === 0 ) {
78
+ $origThumbURL = 'https:'.$origThumbURL;
79
+ }
80
+
81
  $localThumb = LYTE_CACHE_DIR . '/' . md5($origThumbURL) . ".jpg";
82
 
83
  if ( !file_exists($localThumb) || $lyte_thumb_dontsave ) {
161
  if ( !$err && $str != "" ) {
162
  return $str;
163
  } else {
164
+ $lyte_thumb_error .= "curl err: ".$err."/ ";
165
  }
166
  } else {
167
  $lyte_thumb_error .= "no curl/ ";
173
  }
174
 
175
  function lyte_thumb_fallback() {
176
+ global $origThumbURL, $lyte_thumb_error, $lyte_thumb_report_err;
177
  // if for any reason we can't show a local thumbnail, we redirect to the original one
178
  if ( strpos( $origThumbURL, "http" ) !== 0) {
179
  $origThumbURL = "https:".$origThumbURL;
options.php CHANGED
@@ -57,6 +57,7 @@ function register_lyte_settings() {
57
  register_setting( 'lyte-settings-group', 'lyte_greedy' );
58
  register_setting( 'lyte-settings-group', 'lyte_yt_api_key' );
59
  register_setting( 'lyte-settings-group', 'lyte_local_thumb' );
 
60
  }
61
 
62
  function lyte_admin_scripts() {
@@ -194,20 +195,20 @@ function lyte_settings_page() {
194
  <th scope="row"><?php _e("Player size","wp-youtube-lyte") ?>:</th>
195
  <td>
196
  <fieldset><legend class="screen-reader-text"><span><?php _e("Player size","wp-youtube-lyte") ?></span></legend>
197
- <?php
198
- $sel = !is_bool(get_option('lyte_size')) ? (int) get_option('lyte_size') : 0;
199
- foreach (array("169","43") as $f) {
200
- foreach ($pSizeOrder[$f] as $i) {
201
- $pS=$pSize[$i];
202
- if ($pS['a']===true) {
203
- ?>
204
- <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 />
205
- <?php
 
 
 
206
  }
207
- }
208
- ?><br /><?php
209
- }
210
- ?>
211
  </fieldset>
212
  </td>
213
  </tr>
@@ -240,7 +241,7 @@ function lyte_settings_page() {
240
  <label title="<?php _e('Don\'t enable HD playback','wp-youtube-lyte');?>"><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>
241
  </fieldset>
242
  </td>
243
- </tr>
244
  <tr valign="top">
245
  <th scope="row"><?php _e("Add microdata?","wp-youtube-lyte") ?></th>
246
  <td>
@@ -273,7 +274,18 @@ function lyte_settings_page() {
273
  </fieldset>
274
  </td>
275
  </tr>
276
- <tr valign="top">
 
 
 
 
 
 
 
 
 
 
 
277
  <th scope="row"><?php _e("Empty WP YouTube Lyte's cache","wp-youtube-lyte") ?></th>
278
  <td>
279
  <fieldset>
57
  register_setting( 'lyte-settings-group', 'lyte_greedy' );
58
  register_setting( 'lyte-settings-group', 'lyte_yt_api_key' );
59
  register_setting( 'lyte-settings-group', 'lyte_local_thumb' );
60
+ register_setting( 'lyte-settings-group', 'lyte_disclaimer' );
61
  }
62
 
63
  function lyte_admin_scripts() {
195
  <th scope="row"><?php _e("Player size","wp-youtube-lyte") ?>:</th>
196
  <td>
197
  <fieldset><legend class="screen-reader-text"><span><?php _e("Player size","wp-youtube-lyte") ?></span></legend>
198
+ <?php
199
+ $sel = !is_bool(get_option('lyte_size')) ? (int) get_option('lyte_size') : 0;
200
+ foreach (array("169","43") as $f) {
201
+ foreach ($pSizeOrder[$f] as $i) {
202
+ $pS=$pSize[$i];
203
+ if ($pS['a']===true) {
204
+ ?>
205
+ <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 />
206
+ <?php
207
+ }
208
+ }
209
+ ?><br /><?php
210
  }
211
+ ?>
 
 
 
212
  </fieldset>
213
  </td>
214
  </tr>
241
  <label title="<?php _e('Don\'t enable HD playback','wp-youtube-lyte');?>"><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>
242
  </fieldset>
243
  </td>
244
+ </tr>
245
  <tr valign="top">
246
  <th scope="row"><?php _e("Add microdata?","wp-youtube-lyte") ?></th>
247
  <td>
274
  </fieldset>
275
  </td>
276
  </tr>
277
+ <tr valign="top">
278
+ <th scope="row"><?php _e("Text to be added under every LYTE video.","wp-youtube-lyte"); ?></th>
279
+ <td>
280
+ <fieldset>
281
+ <legend class="screen-reader-text"><span><?php _e("Text (e.g. for disclaimer) to be added under every LYTE video.","wp-youtube-lyte") ?></span></legend>
282
+ <input type="text" style="width:100%;" name="lyte_disclaimer" placeholder="" value="<?php echo esc_textarea(get_option('lyte_disclaimer','')); ?>" /><br />
283
+ <br />
284
+ <?php _e("If you want to add e.g. a privacy disclaimer under every LYTE embedded video, you can do so here. Some HTML is allowed. Simply leave empty not to show anything.","wp-youtube-lyte"); ?>
285
+ </fieldset>
286
+ </td>
287
+ </tr>
288
+ <tr valign="top">
289
  <th scope="row"><?php _e("Empty WP YouTube Lyte's cache","wp-youtube-lyte") ?></th>
290
  <td>
291
  <fieldset>
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: 4.9
7
- Stable tag: 1.7.1
8
 
9
  High performance YouTube video, playlist and audio-only embeds which don't slow down your blog and offer optimal accessibility.
10
 
@@ -60,9 +60,9 @@ An API is a way to have two pieces of software talk to each other to exchange in
60
 
61
  4. In the sidebar on the left:
62
  * Click on 'Credentials'
63
- * Click on 'Create new Key'
64
- * Click on 'Server Key'
65
- * Leave the box with whitelisted IP's empty
66
  * Click on 'Create'
67
 
68
  5. Copy your API key to WP YouTube Lyte settings page.
@@ -77,7 +77,7 @@ Just enter "none" (without the quotes) in the API key field and Lyte will stop n
77
  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 for the thumbnails unless the option to cache thumbnails locally is enabled. If thumbnails are cached locally, no request will be sent to YouTube by your visitor's browser until/ unless the video is played.
78
 
79
  = I use a page builder and LYTE does not seem active on the YouTube video's I add there? =
80
- LYTE by default uses WordPress' "the_content"-filter. Page builders don't apply that filter to their content and thus LYTE does not get triggered on those. As a workaround you can the LYTE video using the shortcode in your page-builder Text-block, this works in most page-builders.
81
 
82
  = Can I use WP YouTube Lyte for a custom field? =
83
  Just pass the httpv url of such a field to lyte_preparse like this:
@@ -137,6 +137,10 @@ Just tell me, I like the feedback! Use the [Contact-page on my blog](http://blog
137
 
138
  == Changelog ==
139
 
 
 
 
 
140
  = 1.7.1 =
141
  * Finally fixed a nasty bug that caused API key validation to fail on PHP 7.1 and higher. A big thank you to @emilyatal, @mkalina, @nicolaottomano, @aminech, @partounian, @nicksws who all provided valuable input in [the WordPress LYTE support forum](https://wordpress.org/support/topic/youtube-api-got-error-1-2/) and tested multiple debug-versions to help fix this.
142
 
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: 4.9
7
+ Stable tag: 1.7.2
8
 
9
  High performance YouTube video, playlist and audio-only embeds which don't slow down your blog and offer optimal accessibility.
10
 
60
 
61
  4. In the sidebar on the left:
62
  * Click on 'Credentials'
63
+ * Click on 'Create Credential'
64
+ * Click on 'API key'
65
+ * Set as little restrictions as possible, most problems with getting this working are caused by these settings.
66
  * Click on 'Create'
67
 
68
  5. Copy your API key to WP YouTube Lyte settings page.
77
  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 for the thumbnails unless the option to cache thumbnails locally is enabled. If thumbnails are cached locally, no request will be sent to YouTube by your visitor's browser until/ unless the video is played.
78
 
79
  = I use a page builder and LYTE does not seem active on the YouTube video's I add there? =
80
+ LYTE by default uses WordPress' "the_content"-filter. Page builders don't apply that filter to their content and thus LYTE does not get triggered on those. As a workaround you can add the LYTE video using the shortcode in your page-builder Text-block, this works in most page-builders.
81
 
82
  = Can I use WP YouTube Lyte for a custom field? =
83
  Just pass the httpv url of such a field to lyte_preparse like this:
137
 
138
  == Changelog ==
139
 
140
+ = 1.7.2 =
141
+ * new: you can add a text underneath each video (e.g. for privacy disclaimer purposes, think GDPR) by adding it on the settings-page
142
+ * fix: thumbnails from LYTE without API key can now also be cached locally
143
+
144
  = 1.7.1 =
145
  * Finally fixed a nasty bug that caused API key validation to fail on PHP 7.1 and higher. A big thank you to @emilyatal, @mkalina, @nicolaottomano, @aminech, @partounian, @nicksws who all provided valuable input in [the WordPress LYTE support forum](https://wordpress.org/support/topic/youtube-api-got-error-1-2/) and tested multiple debug-versions to help fix this.
146
 
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.1
8
  Author URI: http://blog.futtta.be/
9
  Text Domain: wp-youtube-lyte
10
  Domain Path: /languages
@@ -82,7 +82,7 @@ add_action('after_setup_theme','lyte_settings_enforcer');
82
 
83
  function lyte_parse($the_content,$doExcerpt=false) {
84
  /** bail if amp */
85
- if ( is_amp()) { return $the_content; }
86
 
87
  /** main function to parse the content, searching and replacing httpv-links */
88
  global $lyteSettings, $toCache_index, $postID, $cachekey;
@@ -237,7 +237,16 @@ function lyte_parse($the_content,$doExcerpt=false) {
237
 
238
  $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></noscript>";
239
  }
240
-
 
 
 
 
 
 
 
 
 
241
  // fetch data from YT api (v2 or v3)
242
  $isPlaylist=false;
243
  if ($plClass===" playlist") {
@@ -339,14 +348,15 @@ function lyte_parse($the_content,$doExcerpt=false) {
339
  $lytetemplate = $wrapper."<div class=\"lyMe".$audioClass.$hidefClass.$plClass.$qsaClass."\" id=\"WYL_".$vid."\"><div id=\"lyte_".$vid."\" data-src=\"".$thumbUrl."\" class=\"pL\">";
340
 
341
  if (isset($yt_resp_array) && !empty($yt_resp_array) && !empty($yt_resp_array["title"])) {
342
- $lytetemplate .= "<div class=\"tC".$titleClass."\"><div class=\"tT\">".$yt_resp_array['title']."</div></div>";
343
- }
344
 
345
  $lytetemplate .= "<div class=\"play\"></div><div class=\"ctrl\"><div class=\"Lctrl\"></div><div class=\"Rctrl\"></div></div></div>".$noscript."</div></div>".$lytelinks_txt;
346
  $templateType="post";
347
  }
348
 
349
  /** API: filter hook to parse template before being applied */
 
350
  $lytetemplate = apply_filters( 'lyte_match_postparse_template',$lytetemplate,$templateType );
351
  $the_content = preg_replace($lytes_regexp, $lytetemplate, $the_content, 1);
352
  }
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.2
8
  Author URI: http://blog.futtta.be/
9
  Text Domain: wp-youtube-lyte
10
  Domain Path: /languages
82
 
83
  function lyte_parse($the_content,$doExcerpt=false) {
84
  /** bail if amp */
85
+ if ( is_amp()) { return str_replace( 'httpv://', 'https://', $the_content ); }
86
 
87
  /** main function to parse the content, searching and replacing httpv-links */
88
  global $lyteSettings, $toCache_index, $postID, $cachekey;
237
 
238
  $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></noscript>";
239
  }
240
+
241
+ // add disclaimer to lytelinks
242
+ $disclaimer = wp_kses_data( get_option( 'lyte_disclaimer', '') );
243
+
244
+ if ( $disclaimer && empty( $lytelinks_txt ) ) {
245
+ $lytelinks_txt = "<div class=\"lL\" style=\"max-width:100%;width:".$lyteSettings[2]."px;".$lyteSettings['pos']."\">".$diclaimer."</div>";
246
+ } else if ( $disclaimer ) {
247
+ $lytelinks_txt = str_replace('</div>','<br/>'.$disclaimer.'</div>',$lytelinks_txt);
248
+ }
249
+
250
  // fetch data from YT api (v2 or v3)
251
  $isPlaylist=false;
252
  if ($plClass===" playlist") {
348
  $lytetemplate = $wrapper."<div class=\"lyMe".$audioClass.$hidefClass.$plClass.$qsaClass."\" id=\"WYL_".$vid."\"><div id=\"lyte_".$vid."\" data-src=\"".$thumbUrl."\" class=\"pL\">";
349
 
350
  if (isset($yt_resp_array) && !empty($yt_resp_array) && !empty($yt_resp_array["title"])) {
351
+ $lytetemplate .= "<div class=\"tC".$titleClass."\"><div class=\"tT\">".$yt_resp_array['title']."</div></div>";
352
+ }
353
 
354
  $lytetemplate .= "<div class=\"play\"></div><div class=\"ctrl\"><div class=\"Lctrl\"></div><div class=\"Rctrl\"></div></div></div>".$noscript."</div></div>".$lytelinks_txt;
355
  $templateType="post";
356
  }
357
 
358
  /** API: filter hook to parse template before being applied */
359
+ $lytetemplate = str_replace('$','&#36;',$lytetemplate);
360
  $lytetemplate = apply_filters( 'lyte_match_postparse_template',$lytetemplate,$templateType );
361
  $the_content = preg_replace($lytes_regexp, $lytetemplate, $the_content, 1);
362
  }