WP YouTube Lyte - Version 0.7.2

Version Description

  • fixed a bug introduced in 0.7.1 which caused httpv-links that were not on newline, not to be turned into a lyte-player
  • added audio as option for widgets as well (consider this beta, not thoroughly tested yet)
Download this release

Release Info

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

Code changes from version 0.7.1 to 0.7.2

Files changed (3) hide show
  1. readme.txt +5 -1
  2. widget.php +21 -1
  3. wp-youtube-lyte.php +2 -2
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: futtta
3
  Tags: youtube, video, lyte, lite youtube embeds, html5 video, html5, widget, youtube audio, audio
4
  Requires at least: 2.9
5
  Tested up to: 3.1.1
6
- Stable tag: 0.7.1
7
 
8
  "Lite YouTube Embeds" look like normal YouTube embeds but don't use Flash, thus reducing download size & page rendering time.
9
 
@@ -54,6 +54,10 @@ and you're good to go!
54
  * [Rate my plugin on wordpress.org](http://wordpress.org/extend/plugins/wp-youtube-lyte/), even if you think it stinks ;-)
55
 
56
  == Changelog ==
 
 
 
 
57
  = 0.7.1 =
58
  * re-minized lyte-min.js (there's lyte.js for your reading pleasure though)
59
  * thumbnail image in noscript-tags now inherits size of div (to keep it from messing up the layout when JS is not available, e.g. in a feedburner-feed)
3
  Tags: youtube, video, lyte, lite youtube embeds, html5 video, html5, widget, youtube audio, audio
4
  Requires at least: 2.9
5
  Tested up to: 3.1.1
6
+ Stable tag: 0.7.2
7
 
8
  "Lite YouTube Embeds" look like normal YouTube embeds but don't use Flash, thus reducing download size & page rendering time.
9
 
54
  * [Rate my plugin on wordpress.org](http://wordpress.org/extend/plugins/wp-youtube-lyte/), even if you think it stinks ;-)
55
 
56
  == Changelog ==
57
+ = 0.7.2 =
58
+ * fixed a bug introduced in 0.7.1 which caused httpv-links that were not on newline, not to be turned into a lyte-player
59
+ * added audio as option for widgets as well (consider this beta, not thoroughly tested yet)
60
+
61
  = 0.7.1 =
62
  * re-minized lyte-min.js (there's lyte.js for your reading pleasure though)
63
  * thumbnail image in noscript-tags now inherits size of div (to keep it from messing up the layout when JS is not available, e.g. in a feedburner-feed)
widget.php CHANGED
@@ -15,6 +15,9 @@ class WYLWidget extends WP_Widget {
15
  $WYLsize = apply_filters( 'widget_text', $instance['WYLsize'], $instance );
16
  if ($WYLsize=="") $WYLsize=$wDefault;
17
 
 
 
 
18
  $WYLurl=esc_url($instance['WYLurl']);
19
  $WYLqs=substr(strstr($WYLurl,'?'),1);
20
  parse_str($WYLqs,$WYLarr);
@@ -29,7 +32,7 @@ class WYLWidget extends WP_Widget {
29
  ?>
30
  <?php echo $before_widget; ?>
31
  <?php if ( $WYLtitle ) echo $before_title . $WYLtitle . $after_title; ?>
32
- <div class="lyte widget" id="<?php echo $WYLid; ?>" style="width:<?php echo $wSize[$WYLsize]['w']; ?>px;height:<?php echo $wSize[$WYLsize]['h']; ?>px;"><noscript><a href="http://youtu.be/<?php echo $WYLid;?>"><img src="http://img.youtube.com/vi/<?php echo $WYLid; ?>/default.jpg" alt="" /></a></noscript><script type="text/javascript"><!--
33
  var bU='<?php echo $lyteSettings[0];?>';var nT='<?php echo $lyteSettings[1];?>';var d=document;if(d.addEventListener){d.addEventListener('DOMContentLoaded', insert, false)}else{window.onload=insert} function insert(){if(!d.getElementById('lytescr')){lytescr=d.createElement('script');lytescr.async=true;lytescr.id='lytescr';lytescr.src='<?php echo $lyteSettings[0]."lyte-min.js";?>';h=d.getElementsByTagName('script')[0];h.parentNode.insertBefore(lytescr, h)}};
34
  --></script></div>
35
  <div><?php echo $WYLtext ?></div>
@@ -42,6 +45,7 @@ class WYLWidget extends WP_Widget {
42
  $instance['WYLtitle'] = strip_tags($new_instance['WYLtitle']);
43
  $instance['WYLurl'] = strip_tags($new_instance['WYLurl']);
44
  $instance['WYLsize'] = strip_tags($new_instance['WYLsize']);
 
45
 
46
  if ( current_user_can('unfiltered_html') )
47
  $instance['WYLtext'] = $new_instance['WYLtext'];
@@ -58,6 +62,9 @@ class WYLWidget extends WP_Widget {
58
  $WYLurl = esc_attr($instance['WYLurl']);
59
  $WYLtext = format_to_edit($instance['WYLtext']);
60
 
 
 
 
61
  $WYLsize = esc_attr($instance['WYLsize']);
62
  if ($WYLsize=="") $WYLsize=$wDefault;
63
 
@@ -79,6 +86,19 @@ class WYLWidget extends WP_Widget {
79
  ?>
80
  </select>
81
  </label></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  <p><label for="<?php echo $this->get_field_id('WYLurl'); ?>"><?php _e('Youtube-URL:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('WYLurl'); ?>" name="<?php echo $this->get_field_name('WYLurl'); ?>" type="text" value="<?php echo $WYLurl; ?>" /></label></p>
83
  <p><label for="<?php echo $this->get_field_id('WYLtext'); ?>"><?php _e('Text:'); ?> <textarea class="widefat" id="<?php echo $this->get_field_id('WYLtext'); ?>" name="<?php echo $this->get_field_name('WYLtext'); ?>" rows="16" cols="20"><?php echo $WYLtext; ?></textarea></label></p>
84
  <?php
15
  $WYLsize = apply_filters( 'widget_text', $instance['WYLsize'], $instance );
16
  if ($WYLsize=="") $WYLsize=$wDefault;
17
 
18
+ $WYLaudio = apply_filters( 'widget_text', $instance['WYLaudio'], $instance );
19
+ if ($WYLaudio!=="audio") $WYLaudio="";
20
+
21
  $WYLurl=esc_url($instance['WYLurl']);
22
  $WYLqs=substr(strstr($WYLurl,'?'),1);
23
  parse_str($WYLqs,$WYLarr);
32
  ?>
33
  <?php echo $before_widget; ?>
34
  <?php if ( $WYLtitle ) echo $before_title . $WYLtitle . $after_title; ?>
35
+ <div class="lyte widget <?php echo $WYLaudio; ?>" id="<?php echo $WYLid; ?>" style="width:<?php echo $wSize[$WYLsize]['w']; ?>px;height:<?php if($WYLaudio==="audio") {echo "25";} else {echo $wSize[$WYLsize]['h'];} ?>px;"><noscript><a href="http://youtu.be/<?php echo $WYLid;?>"><img src="http://img.youtube.com/vi/<?php echo $WYLid; ?>/default.jpg" alt="" /></a></noscript><script type="text/javascript"><!--
36
  var bU='<?php echo $lyteSettings[0];?>';var nT='<?php echo $lyteSettings[1];?>';var d=document;if(d.addEventListener){d.addEventListener('DOMContentLoaded', insert, false)}else{window.onload=insert} function insert(){if(!d.getElementById('lytescr')){lytescr=d.createElement('script');lytescr.async=true;lytescr.id='lytescr';lytescr.src='<?php echo $lyteSettings[0]."lyte-min.js";?>';h=d.getElementsByTagName('script')[0];h.parentNode.insertBefore(lytescr, h)}};
37
  --></script></div>
38
  <div><?php echo $WYLtext ?></div>
45
  $instance['WYLtitle'] = strip_tags($new_instance['WYLtitle']);
46
  $instance['WYLurl'] = strip_tags($new_instance['WYLurl']);
47
  $instance['WYLsize'] = strip_tags($new_instance['WYLsize']);
48
+ $instance['WYLaudio'] = strip_tags($new_instance['WYLaudio']);
49
 
50
  if ( current_user_can('unfiltered_html') )
51
  $instance['WYLtext'] = $new_instance['WYLtext'];
62
  $WYLurl = esc_attr($instance['WYLurl']);
63
  $WYLtext = format_to_edit($instance['WYLtext']);
64
 
65
+ $WYLaudio = esc_attr($instance['WYLaudio']);
66
+ if ($WYLaudio!=="audio") $WYLaudio="";
67
+
68
  $WYLsize = esc_attr($instance['WYLsize']);
69
  if ($WYLsize=="") $WYLsize=$wDefault;
70
 
86
  ?>
87
  </select>
88
  </label></p>
89
+ <p><label for="<?php echo $this->get_field_id('WYLaudio'); ?>"><?php _e('Type:'); ?>
90
+ <select class="widefat" id="<?php echo $this->get_field_id('WYLaudio'); ?>" name="<?php echo $this->get_field_name('WYLaudio'); ?>">
91
+ <?php
92
+ if($WYLaudio==="audio") {
93
+ $aselected=" selected=\"true\"";
94
+ } else {
95
+ $vselected=" selected=\"true\"";
96
+ }
97
+ echo "<option value=\"audio\"".$aselected.">audio</option>";
98
+ echo "<option value=\"video\"".$vselected.">video</option>";
99
+ ?>
100
+ </select>
101
+ </label></p>
102
  <p><label for="<?php echo $this->get_field_id('WYLurl'); ?>"><?php _e('Youtube-URL:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('WYLurl'); ?>" name="<?php echo $this->get_field_name('WYLurl'); ?>" type="text" value="<?php echo $WYLurl; ?>" /></label></p>
103
  <p><label for="<?php echo $this->get_field_id('WYLtext'); ?>"><?php _e('Text:'); ?> <textarea class="widefat" id="<?php echo $this->get_field_id('WYLtext'); ?>" name="<?php echo $this->get_field_name('WYLtext'); ?>" rows="16" cols="20"><?php echo $WYLtext; ?></textarea></label></p>
104
  <?php
wp-youtube-lyte.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: WP YouTube Lyte
4
  Plugin URI: http://blog.futtta.be/tag/lyte
5
  Description: Lite and accessible YouTube audio and video embedding.
6
  Author: Frank Goossens (futtta)
7
- Version: 0.7.1
8
  Author URI: http://blog.futtta.be/
9
  */
10
 
@@ -67,7 +67,7 @@ function lyte_parse($the_content) {
67
  }
68
 
69
  $lytetemplate = "<div class=\"lyte".$audioClass."\" id=\"".$match[4]."\" style=\"width:".$lyteSettings[2]."px;height:".$divHeight."px;\"><noscript><a href=\"http://youtu.be/".$match[4]."\"><img src=\"http://img.youtube.com/vi/".$match[4]."/0.jpg\" alt=\"\" width=\"".$lyteSettings[2]."\" height=\"".$divHeight."\" />".$noscript_post."</a></noscript><script type=\"text/javascript\"><!-- \n var nT='".$lyteSettings[1]."';var bU='".$lyteSettings[0]."';var d=document;if(d.addEventListener){d.addEventListener('DOMContentLoaded', insert, false)}else{window.onload=insert} function insert(){if(!d.getElementById('lytescr')){lytescr=d.createElement('script');lytescr.async=true;lytescr.id='lytescr';lytescr.src='".$lyteSettings[0]."lyte-min.js';h=d.getElementsByTagName('script')[0];h.parentNode.insertBefore(lytescr, h)}}; \n --></script></div>".$lytelinks_txt;
70
- $the_content = preg_replace("/<p>http(v|a):\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/watch(\?v\=|\/v\/)([a-zA-Z0-9\-\_]{11})([^\s<]*)<\/p>/", $lytetemplate, $the_content, 1);
71
  }
72
  }
73
  return $the_content;
4
  Plugin URI: http://blog.futtta.be/tag/lyte
5
  Description: Lite and accessible YouTube audio and video embedding.
6
  Author: Frank Goossens (futtta)
7
+ Version: 0.7.2
8
  Author URI: http://blog.futtta.be/
9
  */
10
 
67
  }
68
 
69
  $lytetemplate = "<div class=\"lyte".$audioClass."\" id=\"".$match[4]."\" style=\"width:".$lyteSettings[2]."px;height:".$divHeight."px;\"><noscript><a href=\"http://youtu.be/".$match[4]."\"><img src=\"http://img.youtube.com/vi/".$match[4]."/0.jpg\" alt=\"\" width=\"".$lyteSettings[2]."\" height=\"".$divHeight."\" />".$noscript_post."</a></noscript><script type=\"text/javascript\"><!-- \n var nT='".$lyteSettings[1]."';var bU='".$lyteSettings[0]."';var d=document;if(d.addEventListener){d.addEventListener('DOMContentLoaded', insert, false)}else{window.onload=insert} function insert(){if(!d.getElementById('lytescr')){lytescr=d.createElement('script');lytescr.async=true;lytescr.id='lytescr';lytescr.src='".$lyteSettings[0]."lyte-min.js';h=d.getElementsByTagName('script')[0];h.parentNode.insertBefore(lytescr, h)}}; \n --></script></div>".$lytelinks_txt;
70
+ $the_content = preg_replace("/(<p>)?http(v|a):\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/watch(\?v\=|\/v\/)([a-zA-Z0-9\-\_]{11})([^\s<]*)(<\/p>)?/", $lytetemplate, $the_content, 1);
71
  }
72
  }
73
  return $the_content;