WP YouTube Lyte - Version 1.7.15

Version Description

  • To avoid YouTube cutting API access because no requests were made for 3 months, LYTE now by default caches the YouTube data for 2 months, after which it is refreshed. Previously cached data only refreshed if the cache got cleared manually.
Download this release

Release Info

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

Code changes from version 1.7.14 to 1.7.15

Files changed (2) hide show
  1. readme.txt +5 -2
  2. wp-youtube-lyte.php +20 -12
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: 5.5
7
- Stable tag: 1.7.14
8
 
9
  High performance YouTube video, playlist and audio-only embeds which don't slow down your blog and offer optimal accessibility.
10
 
@@ -140,6 +140,9 @@ Just tell me, I like the feedback! Use the [Contact-page on my blog](http://blog
140
 
141
  == Changelog ==
142
 
 
 
 
143
  = 1.7.14 =
144
  * fix WordPress core blocks "recent posts block" breaking when summary or full article were shown.
145
  * remove old language-files (translations are now entirely handled via https://translate.wordpress.org/projects/wp-plugins/wp-youtube-lyte/
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: 5.7
7
+ Stable tag: 1.7.15
8
 
9
  High performance YouTube video, playlist and audio-only embeds which don't slow down your blog and offer optimal accessibility.
10
 
140
 
141
  == Changelog ==
142
 
143
+ = 1.7.15 =
144
+ * To avoid YouTube cutting API access because no requests were made for 3 months, LYTE now by default caches the YouTube data for 2 months, after which it is refreshed. Previously cached data only refreshed if the cache got cleared manually.
145
+
146
  = 1.7.14 =
147
  * fix WordPress core blocks "recent posts block" breaking when summary or full article were shown.
148
  * remove old language-files (translations are now entirely handled via https://translate.wordpress.org/projects/wp-plugins/wp-youtube-lyte/
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.14
8
  Author URI: http://blog.futtta.be/
9
  Text Domain: wp-youtube-lyte
10
  */
@@ -12,7 +12,7 @@ Text Domain: wp-youtube-lyte
12
  if ( ! defined( 'ABSPATH' ) ) exit;
13
 
14
  $debug=false;
15
- $lyte_version="1.7.14";
16
  $lyte_db_version=get_option('lyte_version','none');
17
 
18
  /** have we updated? */
@@ -123,9 +123,11 @@ function lyte_parse($the_content,$doExcerpt=false) {
123
  if (apply_filters('lyte_remove_wpautop',false)) {
124
  remove_filter('the_content','wpautop');
125
  }
126
- $char_codes = array('×','–','\u002d');
127
- $replacements = array("x", "--", "-");
128
- $the_content=str_replace($char_codes, $replacements, $the_content);
 
 
129
  $lyte_feed=is_feed();
130
 
131
  $hidefClass = ($lyteSettings['hidef']==="1") ? " hidef" : "";
@@ -404,10 +406,12 @@ function lyte_parse($the_content,$doExcerpt=false) {
404
  }
405
  }
406
 
407
- // replace remaining double dash but restore it in comment tags (this is getting ugly though).
408
- $the_content = str_replace( array( ' -- ', '-- ', ' --' ), ' – ', $the_content );
409
- $the_content = str_replace( '<! &#8211;', '<!--', $the_content );
410
- $the_content = str_replace( '&#8211; >', '-->', $the_content );
 
 
411
 
412
  /** API: filter hook to postparse the_content before returning */
413
  $the_content = apply_filters( 'lyte_content_postparse',$the_content );
@@ -445,7 +449,7 @@ function captions_lookup($postID, $cachekey, $vid) {
445
  }
446
  }
447
 
448
- function lyte_get_YT_resp($vid,$playlist=false,$cachekey,$apiTestKey="",$isWidget=false) {
449
  /** logic to get video info from cache or get it from YouTube and set it */
450
  global $postID, $cachekey, $toCache_index;
451
 
@@ -471,8 +475,12 @@ function lyte_get_YT_resp($vid,$playlist=false,$cachekey,$apiTestKey="",$isWidge
471
  }
472
  }
473
 
474
- if ( empty( $_thisLyte ) ) {
475
- // get info from youtube
 
 
 
 
476
  // first get yt api key
477
  $lyte_yt_api_key = get_option('lyte_yt_api_key','');
478
  $lyte_yt_api_key = apply_filters('lyte_filter_yt_api_key', $lyte_yt_api_key);
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.15
8
  Author URI: http://blog.futtta.be/
9
  Text Domain: wp-youtube-lyte
10
  */
12
  if ( ! defined( 'ABSPATH' ) ) exit;
13
 
14
  $debug=false;
15
+ $lyte_version = '1.7.15';
16
  $lyte_db_version=get_option('lyte_version','none');
17
 
18
  /** have we updated? */
123
  if (apply_filters('lyte_remove_wpautop',false)) {
124
  remove_filter('the_content','wpautop');
125
  }
126
+ if ( apply_filters( 'lyte_kinda_textureize', true ) ) {
127
+ $char_codes = array('&#215;','&#8211;','\u002d');
128
+ $replacements = array("x", "--", "-");
129
+ $the_content=str_replace($char_codes, $replacements, $the_content);
130
+ }
131
  $lyte_feed=is_feed();
132
 
133
  $hidefClass = ($lyteSettings['hidef']==="1") ? " hidef" : "";
406
  }
407
  }
408
 
409
+ if ( apply_filters( 'lyte_kinda_textureize', true ) ) {
410
+ // replace remaining double dash but restore it in comment tags (this is getting ugly though).
411
+ $the_content = str_replace( array( ' -- ', '-- ', ' --' ), ' &#8211; ', $the_content );
412
+ $the_content = str_replace( '<! &#8211;', '<!--', $the_content );
413
+ $the_content = str_replace( '&#8211; >', '-->', $the_content );
414
+ }
415
 
416
  /** API: filter hook to postparse the_content before returning */
417
  $the_content = apply_filters( 'lyte_content_postparse',$the_content );
449
  }
450
  }
451
 
452
+ function lyte_get_YT_resp( $vid, $playlist=false, $cachekey='', $apiTestKey='', $isWidget=false ) {
453
  /** logic to get video info from cache or get it from YouTube and set it */
454
  global $postID, $cachekey, $toCache_index;
455
 
475
  }
476
  }
477
 
478
+ // set caching duration used to check if data is fresh enough, default max cachetime is 2 months.
479
+ $_lyte_cache_gracetime = apply_filters( 'lyte_ytapi_cache_gracetime', 2 * 30 * 24 * 60 * 60 );
480
+ $_lyte_cache_time_expired = time() - $_lyte_cache_gracetime;
481
+
482
+ if ( empty( $_thisLyte ) || ( apply_filters( 'lyte_ytapi_check_cache', true ) && $_thisLyte['lyte_date_added'] < $_lyte_cache_time_expired ) ) {
483
+ // no result from cache or expired so fetch info from youtube
484
  // first get yt api key
485
  $lyte_yt_api_key = get_option('lyte_yt_api_key','');
486
  $lyte_yt_api_key = apply_filters('lyte_filter_yt_api_key', $lyte_yt_api_key);