Smart YouTube PRO - Version 2.0

Version Description

Download this release

Release Info

Developer freediver
Plugin Icon 128x128 Smart YouTube PRO
Version 2.0
Comparing to
See all releases

Code changes from version 1.91 to 2.0

Files changed (3) hide show
  1. readme.txt +22 -11
  2. screenshot-1.png +0 -0
  3. smartyoutube.php +51 -25
readme.txt CHANGED
@@ -11,34 +11,43 @@ Smart Youtube plugin allows you to insert full featured YouTube videos into your
11
 
12
  == Description ==
13
 
14
- Smart Youtube is a Wordpress Youtube Plugin that allows you to easily insert Youtube videos in your post, comments and in RSS feed. It is small, fast and does not depend on any external scripts.
15
 
16
  The main purpose of the plugin is to correctly embed youtube videos into your blog post. The video will be shown in full in your RSS feed as well.
17
 
18
- The plugin is designed to be small and fast and not use any external resources. It has a number of cutomizable options.
19
 
20
- Changes v1.91:
 
 
 
 
 
 
 
 
 
21
  Rewritten old parts of plugin and general tweaks.
22
 
23
- Changes v1.9:
24
  Added video autoplay option.
25
 
26
- Changes v1.8:
27
  Solved problem with HTML validation, added full video in RSS feed.
28
 
29
- Changes v1.6:
30
  Solved problem with WordPress handling special characters.
31
 
32
- Changes v1.5:
33
  Reworked admin interface, add more features like video color and border.
34
 
35
- Changes v1.4:
36
  All youtube servers work now (like uk.youtube.com, es.youtube.com).
37
 
38
- Changes v1.3:
39
  The plugin now allows embedding video in comments too. Syntax is the same.
40
 
41
- Changes v1.2:
42
  Added Width and Height option and made plugin code xHTML valid.
43
 
44
  == Credits ==
@@ -56,12 +65,14 @@ Thanks.
56
  1. Upload the whole plugin folder to your /wp-content/plugins/ folder.
57
  2. Go to the Plugins page and activate the plugin.
58
  3. Use the Options page to change your options
59
- 4. When you want to display Youtube video in your post, paste the video URL with httpv:// (notice the v)
60
 
61
  The video will be automatically embedded to your post in the proper way.
62
 
63
  Example: httpv://www.youtube.com/watch?v=OWfksMD4PAg
64
 
 
 
65
  Additionally, you can set how do you want the video to be displayed in your RSS feed. Smart Youtube can show the preview image of the video (automatically grabbed from Youtube), the link to the video, or both. I recommend enabling only the preview image.
66
 
67
  == Screenshots ==
11
 
12
  == Description ==
13
 
14
+ Smart Youtube is a Wordpress Youtube Plugin that allows you to easily insert Youtube videos in your post, comments and in RSS feed.
15
 
16
  The main purpose of the plugin is to correctly embed youtube videos into your blog post. The video will be shown in full in your RSS feed as well.
17
 
18
+ From version 2.0 Smart youtube also supports high quality videos.
19
 
20
+ The plugin is designed to be small and fast and not use any external resources. It has a number of customizable options.
21
+
22
+
23
+
24
+
25
+ Change Log:
26
+ v2.0:
27
+ Suport for high quality videos from youtube
28
+
29
+ v1.91:
30
  Rewritten old parts of plugin and general tweaks.
31
 
32
+ v1.9:
33
  Added video autoplay option.
34
 
35
+ v1.8:
36
  Solved problem with HTML validation, added full video in RSS feed.
37
 
38
+ v1.6:
39
  Solved problem with WordPress handling special characters.
40
 
41
+ v1.5:
42
  Reworked admin interface, add more features like video color and border.
43
 
44
+ v1.4:
45
  All youtube servers work now (like uk.youtube.com, es.youtube.com).
46
 
47
+ v1.3:
48
  The plugin now allows embedding video in comments too. Syntax is the same.
49
 
50
+ v1.2:
51
  Added Width and Height option and made plugin code xHTML valid.
52
 
53
  == Credits ==
65
  1. Upload the whole plugin folder to your /wp-content/plugins/ folder.
66
  2. Go to the Plugins page and activate the plugin.
67
  3. Use the Options page to change your options
68
+ 4. When you want to display Youtube video in your post, copy the video URL to your post and change http:// to httpv:// (notice the 'v' character)
69
 
70
  The video will be automatically embedded to your post in the proper way.
71
 
72
  Example: httpv://www.youtube.com/watch?v=OWfksMD4PAg
73
 
74
+ If you want to post a high quality video (not all youtube videos exist in high quality mode so check this first) you would use httpvh:// ('vh' for video high)
75
+
76
  Additionally, you can set how do you want the video to be displayed in your RSS feed. Smart Youtube can show the preview image of the video (automatically grabbed from Youtube), the link to the video, or both. I recommend enabling only the preview image.
77
 
78
  == Screenshots ==
screenshot-1.png CHANGED
Binary file
smartyoutube.php CHANGED
@@ -4,10 +4,11 @@ Plugin Name: Smart Youtube
4
  Plugin URI: http://www.prelovac.com/vladimir/wordpress-plugins/smart-youtube
5
  Description: Easily insert YouTube videos in posts, comments and RSS feeds.
6
  Author: Vladimir Prelovac
7
- Version: 1.91
8
  Author URI: http://www.prelovac.com/vladimir/
9
 
10
  Updates:
 
11
  1.9 - Added video autoplay option
12
  1.8 - Solved Problem with HTML validation, enabled full video preview in RSS
13
  1.6 - Solving a problem with wordpress handling special characters
@@ -18,7 +19,7 @@ To-Doo:
18
  - localization
19
  */
20
 
21
- $yte_localversion="1.91";
22
 
23
  $CustomColors=array (
24
  "blank" => array("d6d6d6","f0f0f0"),
@@ -70,12 +71,18 @@ function yte_options_page()
70
  update_option('smart_yt_img', $disp_img);
71
  update_option('smart_yt_link', $disp_link);
72
 
73
- $disp_width = ($_POST['disp_width']=="")? '425': $_POST['disp_width'];
74
- $disp_height = ($_POST['disp_height']=="")? '355': $_POST['disp_height'];
75
 
76
  update_option('smart_yt_width', $disp_width);
77
  update_option('smart_yt_height', $disp_height);
78
 
 
 
 
 
 
 
79
  $disp_rel = !isset($_POST['embedRel'])? '1': $_POST['embedRel'];
80
  $disp_border = !isset($_POST['embedBorder'])? '0': '1';
81
  $disp_color = !isset($_POST['embedColor'])? 'blank': $_POST['embedColor'];
@@ -114,6 +121,9 @@ function yte_options_page()
114
  $disp_width = get_option('smart_yt_width');
115
  $disp_height = get_option('smart_yt_height');
116
 
 
 
 
117
  $disp_autoplay = (get_option('smart_yt_autoplay')=='1') ? 'checked':'';
118
 
119
 
@@ -275,16 +285,16 @@ text-decoration:none;
275
  <div id="sideblock" style="float:right;width:220px;margin-left:10px;">
276
  <h3>Information</h3>
277
  <div id="dbx-content" style="text-decoration:none;">
278
- <img src="$imgpath/home.png"><a href="http://www.prelovac.com/vladimir/wordpress-plugins/smart-youtube"> Smart YouTube Home</a><br /><br />
279
- <img src="$imgpath/help.png"><a href="http://www.prelovac.com/vladimir/wordpress-plugins/smart-youtube#comments"> Suggest a Feature</a><br /><br />
280
- <img src="$imgpath/rate.png"><a href="http://wordpress.org/extend/plugins/smart-youtube/"> Rate Smart YouTube</a><br /><br />
281
- <img src="$imgpath/more.png"><a href="http://www.prelovac.com/vladimir/wordpress-plugins"> My WordPress Plugins</a><br /><br />
282
  <br />
283
 
284
  <p align="center">
285
  <img src="$imgpath/p1.png"></p>
286
 
287
- <p> <img src="$imgpath/idea.png"><a href="http://www.prelovac.com/vladimir/services"> Need a WordPress Expert?</a></p>
288
  </div>
289
  </div>
290
 
@@ -293,13 +303,15 @@ text-decoration:none;
293
  <div class="dbx-content">
294
  <form name="yteform" action="$action_url" method="post">
295
  <input type="hidden" name="submitted" value="1" />
296
- <h3> General Options</h3>
297
 
298
  <p>To use the video in your posts, paste YouTube video URL with <strong>httpv://</strong> (notice the 'v'). </p>
299
- <p><strong>Important:</strong> The URL should just be pasted into your post as normal text, do not create a link as it will not work.</p>
300
  <p>Example: httpv://www.youtube.com/watch?v=OWfksMD4PAg</p>
 
301
 
302
-
 
303
  <p><strong>Video settings</strong></p>
304
 
305
  <div><input id="check3" type="checkbox" name="disp_posts" $disp_posts />
@@ -311,12 +323,12 @@ text-decoration:none;
311
 
312
  <br><br><strong>Video Appearence</strong><br><br>
313
 
 
 
314
 
315
- <div><input id="disp_width" name="disp_width" value="$disp_width"/>
316
- <label for="disp_width">Width</label></div>
317
 
318
- <div><input id="disp_height" name="disp_height" value="$disp_height"/>
319
- <label for="disp_height">Height</label></div>
320
 
321
  <br />
322
  <div id="watch-customize-embed-form">
@@ -376,33 +388,35 @@ add_action('admin_menu', 'yte_add_pages');
376
 
377
 
378
 
379
- function yte_tag($file) {
380
  global $CustomColors;
381
 
382
- $width=get_option('smart_yt_width');
383
- $height=get_option('smart_yt_height');
384
 
385
  $disp_rel = get_option('smart_yt_rel');
386
  $disp_border = get_option('smart_yt_border');
387
  $disp_color = get_option('smart_yt_color');
388
  $autoplay = get_option('smart_yt_autoplay');
389
 
 
 
390
  if ($width=="")
391
- $width="425";
392
  if ($height=="")
393
- $height="355";
394
 
395
  if ($disp_border)
396
  $height+=18;
397
 
398
- $yte_tag = '<!-- Smart Youtube --><span class="youtube"><object width="'.$width.'" height="'.$height.'" type="application/x-shockwave-flash" data="'.htmlspecialchars('http://www.youtube.com/v/'.$file.'&rel='.$disp_rel.'&color1='.$CustomColors[$disp_color][0].'&color2='.$CustomColors[$disp_color][1].'&border='.$disp_border.'&autoplay='.$autoplay, ENT_QUOTES).'"> <param name="movie" value="'.htmlspecialchars('http://www.youtube.com/v/'.$file.'&rel='.$disp_rel.'&color1='.$CustomColors[$disp_color][0].'&color2='.$CustomColors[$disp_color][1].'&border='.$disp_border.'&autoplay='.$autoplay, ENT_QUOTES).'" /><param name="wmode" value="transparent" /></object></span>';
399
 
400
  if (is_feed())
401
  {
402
  if (get_option('smart_yt_img')=='on')
403
- $yte_tag.='<a href="http://www.youtube.com/watch?v='.$file.'"><img src="http://img.youtube.com/vi/'.$file.'/default.jpg" width="130" height="97" border=0></a>';
404
  if (get_option('smart_yt_link')=='on')
405
- $yte_tag.='<a href="http://www.youtube.com/watch?v='.$file.'">www.youtube.com/watch?v='.$file.'</a>';
406
  // if ( (get_option('smart_yt_link')=='off') && (get_option('smart_yt_img')=='off') )
407
  // $yte_tag='http://www.youtube.com/watch?v='.$file;
408
  }
@@ -419,7 +433,12 @@ function yte_check($the_content) {
419
 
420
  preg_match_all("/httpv:\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/watch(\?v\=|\/v\/)([a-zA-Z0-9\-\_]{11})([^<\s]*)/", $the_content, $matches, PREG_SET_ORDER);
421
  foreach($matches as $match) {
422
- $the_content = preg_replace("/httpv:\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/watch(\?v\=|\/v\/)([a-zA-Z0-9\-\_]{11})([^\s<]*)/", yte_tag($match[3]), $the_content, 1);
 
 
 
 
 
423
  }
424
  }
425
  return $the_content;
@@ -437,6 +456,13 @@ function yte_install(){
437
  add_option('smart_yt_height', '355');
438
  }
439
 
 
 
 
 
 
 
 
440
  if(get_option('smart_yt_rel' == '') || !get_option('smart_yt_rel')){
441
  add_option('smart_yt_rel', '1');
442
  }
4
  Plugin URI: http://www.prelovac.com/vladimir/wordpress-plugins/smart-youtube
5
  Description: Easily insert YouTube videos in posts, comments and RSS feeds.
6
  Author: Vladimir Prelovac
7
+ Version: 2.0
8
  Author URI: http://www.prelovac.com/vladimir/
9
 
10
  Updates:
11
+ 2.0 - Support for playback high quality YouTube videos
12
  1.9 - Added video autoplay option
13
  1.8 - Solved Problem with HTML validation, enabled full video preview in RSS
14
  1.6 - Solving a problem with wordpress handling special characters
19
  - localization
20
  */
21
 
22
+ $yte_localversion="2.0";
23
 
24
  $CustomColors=array (
25
  "blank" => array("d6d6d6","f0f0f0"),
71
  update_option('smart_yt_img', $disp_img);
72
  update_option('smart_yt_link', $disp_link);
73
 
74
+ $disp_width = (int) ($_POST['disp_width']=="")? '425': $_POST['disp_width'];
75
+ $disp_height = (int) ($_POST['disp_height']=="")? '344': $_POST['disp_height'];
76
 
77
  update_option('smart_yt_width', $disp_width);
78
  update_option('smart_yt_height', $disp_height);
79
 
80
+ $disp_widthhq = (int) ($_POST['disp_widthhq']=="")? '480': $_POST['disp_widthhq'];
81
+ $disp_heighthq = (int) ($_POST['disp_heighthq']=="")? '360': $_POST['disp_heighthq'];
82
+
83
+ update_option('smart_yt_widthhq', $disp_widthhq);
84
+ update_option('smart_yt_heighthq', $disp_heighthq);
85
+
86
  $disp_rel = !isset($_POST['embedRel'])? '1': $_POST['embedRel'];
87
  $disp_border = !isset($_POST['embedBorder'])? '0': '1';
88
  $disp_color = !isset($_POST['embedColor'])? 'blank': $_POST['embedColor'];
121
  $disp_width = get_option('smart_yt_width');
122
  $disp_height = get_option('smart_yt_height');
123
 
124
+ $disp_widthhq = get_option('smart_yt_widthhq');
125
+ $disp_heighthq = get_option('smart_yt_heighthq');
126
+
127
  $disp_autoplay = (get_option('smart_yt_autoplay')=='1') ? 'checked':'';
128
 
129
 
285
  <div id="sideblock" style="float:right;width:220px;margin-left:10px;">
286
  <h3>Information</h3>
287
  <div id="dbx-content" style="text-decoration:none;">
288
+ <img src="$imgpath/home.png"><a style="text-decoration:none;" href="http://www.prelovac.com/vladimir/wordpress-plugins/smart-youtube"> Smart YouTube Home</a><br /><br />
289
+ <img src="$imgpath/help.png"><a style="text-decoration:none;" href="http://www.prelovac.com/vladimir/wordpress-plugins/smart-youtube#comments"> Suggest a Feature</a><br /><br />
290
+ <img src="$imgpath/rate.png"><a style="text-decoration:none;" href="http://wordpress.org/extend/plugins/smart-youtube/"> Rate Smart YouTube</a><br /><br />
291
+ <img src="$imgpath/more.png"><a style="text-decoration:none;" href="http://www.prelovac.com/vladimir/wordpress-plugins"> My WordPress Plugins</a><br /><br />
292
  <br />
293
 
294
  <p align="center">
295
  <img src="$imgpath/p1.png"></p>
296
 
297
+ <p> <img src="$imgpath/idea.png"><a style="text-decoration:none;" href="http://www.prelovac.com/vladimir/services"> Need a WordPress Expert?</a></p>
298
  </div>
299
  </div>
300
 
303
  <div class="dbx-content">
304
  <form name="yteform" action="$action_url" method="post">
305
  <input type="hidden" name="submitted" value="1" />
306
+ <h3>Usage</h3>
307
 
308
  <p>To use the video in your posts, paste YouTube video URL with <strong>httpv://</strong> (notice the 'v'). </p>
309
+ <p><strong>Important:</strong> The URL should just be copied into your post normally and the letter 'v' added, do not create a link of it.</p>
310
  <p>Example: httpv://www.youtube.com/watch?v=OWfksMD4PAg</p>
311
+ <p>If you want to embed high quality video (for thuse videos that have their HQ counterparts) use httpvh:// instead (video high).</p>
312
 
313
+ <h3>Options</h3>
314
+ <p> You can adjust the way your embeded youtube videos behave in the options below.</p>
315
  <p><strong>Video settings</strong></p>
316
 
317
  <div><input id="check3" type="checkbox" name="disp_posts" $disp_posts />
323
 
324
  <br><br><strong>Video Appearence</strong><br><br>
325
 
326
+ <p>Video width and height in normal mode. Default is 425x344.</p>
327
+ <input id="disp_width" name="disp_width" value="$disp_width" size="7"/>x<input id="disp_height" name="disp_height" value="$disp_height" size="7" /><br>
328
 
 
 
329
 
330
+ <p>Video width and height in <strong>high quality</strong> mode. Default is 480x360.</p>
331
+ <input id="disp_widthhq" name="disp_widthhq" value="$disp_widthhq" size="7" />x<input id="disp_heighthq" name="disp_heighthq" value="$disp_heighthq" size="7" /><br><br>
332
 
333
  <br />
334
  <div id="watch-customize-embed-form">
388
 
389
 
390
 
391
+ function yte_tag($file, $high=0) {
392
  global $CustomColors;
393
 
394
+ $width=$high ? get_option('smart_yt_widthhq') : get_option('smart_yt_width');
395
+ $height=$high ? get_option('smart_yt_height') : get_option('smart_yt_height');
396
 
397
  $disp_rel = get_option('smart_yt_rel');
398
  $disp_border = get_option('smart_yt_border');
399
  $disp_color = get_option('smart_yt_color');
400
  $autoplay = get_option('smart_yt_autoplay');
401
 
402
+ $high= $high ? "&ap=%2526fmt%3D18" : "" ;
403
+
404
  if ($width=="")
405
+ $width=$high ? "480" : "425" ;
406
  if ($height=="")
407
+ $height= $high ? "360" : "344";
408
 
409
  if ($disp_border)
410
  $height+=18;
411
 
412
+ $yte_tag = '<!-- Smart Youtube --><span class="youtube"><object width="'.$width.'" height="'.$height.'" type="application/x-shockwave-flash" data="'.htmlspecialchars('http://www.youtube.com/v/'.$file.'&rel='.$disp_rel.'&color1='.$CustomColors[$disp_color][0].'&color2='.$CustomColors[$disp_color][1].'&border='.$disp_border.'&fs=1&autoplay='.$autoplay.$high, ENT_QUOTES).'"> <param name="movie" value="'.htmlspecialchars('http://www.youtube.com/v/'.$file.'&rel='.$disp_rel.'&color1='.$CustomColors[$disp_color][0].'&color2='.$CustomColors[$disp_color][1].'&border='.$disp_border.'&fs=1&autoplay='.$autoplay.$high, ENT_QUOTES).'" /><param name="wmode" value="transparent" /></object></span>';
413
 
414
  if (is_feed())
415
  {
416
  if (get_option('smart_yt_img')=='on')
417
+ $yte_tag.='<a href="http://www.youtube.com/watch?v='.$file.$high.'"><img src="http://img.youtube.com/vi/'.$file.'/default.jpg" width="130" height="97" border=0></a>';
418
  if (get_option('smart_yt_link')=='on')
419
+ $ytE_tag.='<a href="http://www.youtube.com/watch?v='.$file.$high.'">www.youtube.com/watch?v='.$file.'</a>';
420
  // if ( (get_option('smart_yt_link')=='off') && (get_option('smart_yt_img')=='off') )
421
  // $yte_tag='http://www.youtube.com/watch?v='.$file;
422
  }
433
 
434
  preg_match_all("/httpv:\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/watch(\?v\=|\/v\/)([a-zA-Z0-9\-\_]{11})([^<\s]*)/", $the_content, $matches, PREG_SET_ORDER);
435
  foreach($matches as $match) {
436
+ $the_content = preg_replace("/httpv:\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/watch(\?v\=|\/v\/)([a-zA-Z0-9\-\_]{11})([^\s<]*)/", yte_tag($match[3], 0), $the_content, 1);
437
+ }
438
+
439
+ preg_match_all("/httpvh:\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/watch(\?v\=|\/v\/)([a-zA-Z0-9\-\_]{11})([^<\s]*)/", $the_content, $matches, PREG_SET_ORDER);
440
+ foreach($matches as $match) {
441
+ $the_content = preg_replace("/httpvh:\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/watch(\?v\=|\/v\/)([a-zA-Z0-9\-\_]{11})([^\s<]*)/", yte_tag($match[3], 1), $the_content, 1);
442
  }
443
  }
444
  return $the_content;
456
  add_option('smart_yt_height', '355');
457
  }
458
 
459
+ if(get_option('smart_yt_widthhq' == '') || !get_option('smart_yt_widthhq')){
460
+ add_option('smart_yt_widthhq', '480');
461
+ }
462
+ if(get_option('smart_yt_heighthq' == '') || !get_option('smart_yt_heighthq')){
463
+ add_option('smart_yt_heighthq', '360');
464
+ }
465
+
466
  if(get_option('smart_yt_rel' == '') || !get_option('smart_yt_rel')){
467
  add_option('smart_yt_rel', '1');
468
  }