WP YouTube Lyte - Version 1.7.10

Version Description

  • fix regression for YouTube embed WordPress block (https://wordpress.org/support/topic/errors-caused-by-upgrading-to-version-1-7-9/) due to changed priority in 1.7.9.
Download this release

Release Info

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

Code changes from version 1.7.9 to 1.7.10

Files changed (2) hide show
  1. readme.txt +4 -1
  2. wp-youtube-lyte.php +26 -20
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.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,6 +135,9 @@ Just tell me, I like the feedback! Use the [Contact-page on my blog](http://blog
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
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.10
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.10 =
139
+ * fix regression for YouTube embed WordPress block (https://wordpress.org/support/topic/errors-caused-by-upgrading-to-version-1-7-9/) due to changed priority in 1.7.9.
140
+
141
  = 1.7.9 =
142
  * improved AMP checking (LYTE should never be active on AMP pages)
143
  * improvements to gutenberg block parsing
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.9
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.9";
17
  $lyte_db_version=get_option('lyte_version','none');
18
 
19
  /** have we updated? */
@@ -112,24 +112,6 @@ function lyte_parse($the_content,$doExcerpt=false) {
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
- *
119
- * having Gutenberg markup in HTML comments is ugly as hell
120
- * esp. for 3rd parties such as Lyte who have to parse info out of that
121
- *
122
- * Luke Cavanagh; thanks for the Gutenbeard reference and for the funny animated gif :)
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
-
133
  if((strpos($the_content, "httpv")!==FALSE)||(strpos($the_content, "httpa")!==FALSE)) {
134
  if (apply_filters('lyte_remove_wpautop',false)) {
135
  remove_filter('the_content','wpautop');
@@ -748,11 +730,35 @@ if (!function_exists("is_amp")) {
748
  }
749
  }
750
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
751
  /** hooking it all up to wordpress */
752
  if ( is_admin() ) {
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');
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.10
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.10";
17
  $lyte_db_version=get_option('lyte_version','none');
18
 
19
  /** have we updated? */
112
  }
113
  }
114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  if((strpos($the_content, "httpv")!==FALSE)||(strpos($the_content, "httpa")!==FALSE)) {
116
  if (apply_filters('lyte_remove_wpautop',false)) {
117
  remove_filter('the_content','wpautop');
730
  }
731
  }
732
 
733
+ function lyte_do_gutenberg( $the_content ) {
734
+ if ( strpos( $the_content, "<!-- wp:" ) !== false && strpos( $the_content, "youtu" ) !== false ) {
735
+ /*
736
+ * do Gutenberg stuff here, playlists if needed first and then single videos
737
+ *
738
+ * having Gutenberg markup in HTML comments is ugly as hell
739
+ * esp. for 3rd parties such as Lyte who have to parse info out of that
740
+ *
741
+ * Luke Cavanagh; thanks for the Gutenbeard reference and for the funny animated gif :)
742
+ * https://media1.giphy.com/media/l2QZTNMFTQ2Z00zHG/giphy.gif
743
+ */
744
+ if ( strpos( $the_content, '/playlist?list=' ) !== false ) {
745
+ $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';
746
+ $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);
747
+ }
748
+ $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';
749
+ $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);
750
+ }
751
+ return $the_content;
752
+ }
753
+
754
  /** hooking it all up to wordpress */
755
  if ( is_admin() ) {
756
  require_once(dirname(__FILE__).'/options.php');
757
  add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'lyte_add_action_link' );
758
  } else {
759
+ if ( apply_filters( 'lyte_filter_do_gutenberg', true ) ) {
760
+ add_filter('the_content', 'lyte_do_gutenberg', 4);
761
+ }
762
  add_filter('the_content', 'lyte_parse', 10);
763
  add_shortcode("lyte", "shortcode_lyte");
764
  remove_filter('get_the_excerpt', 'wp_trim_excerpt');