Smart YouTube PRO - Version 3.5

Version Description

  • Fixed Iphone Issues
Download this release

Release Info

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

Code changes from version 3.4.1 to 3.5

Files changed (4) hide show
  1. readme.txt +8 -1
  2. screenshot-1.png +0 -0
  3. smartyoutube.class.php +46 -64
  4. smartyoutube.php +4 -1
readme.txt CHANGED
@@ -36,7 +36,14 @@ Plugin by Vladimir Prelovac. Looking for <a href="http://www.prelovac.com/vladim
36
 
37
  == Changelog ==
38
 
39
- = 3.4.1=
 
 
 
 
 
 
 
40
  * Fixed widget problem
41
 
42
  = 3.4 =
36
 
37
  == Changelog ==
38
 
39
+ = 3.5 =
40
+ * Fixed Iphone Issues
41
+
42
+ = 3.4.3 =
43
+ * Fixed privacy option
44
+ * Supports new #! style Youtube URLs
45
+
46
+ = 3.4.1 =
47
  * Fixed widget problem
48
 
49
  = 3.4 =
screenshot-1.png CHANGED
Binary file
smartyoutube.class.php CHANGED
@@ -105,7 +105,7 @@ class SmartYouTube
105
  $this->options['border'] = !isset($_POST['embedBorder']) ? 0 : 1;
106
  $this->options['color'] = !isset($_POST['embedColor']) ? 'blank' : $_POST['embedColor'];
107
  $this->options['autoplay'] = !isset($_POST['autoplay']) ? 0 : 1;
108
- $this->options['privacy'] = !isset($_POST['disp_ann']) ? 0 : 1;
109
 
110
  $this->options['posts'] = !isset($_POST['disp_posts']) ? 'off' : 'on';
111
  $this->options['comments'] = !isset($_POST['disp_comments']) ? 'off' : 'on';
@@ -331,7 +331,7 @@ class SmartYouTube
331
  </div>
332
 
333
  <h3>xHTML validation</h3>
334
- <p class="instruct">Enabling the option below will make your YouTube code xHTML valid. </p>
335
  <input id="valid" type="checkbox" name="valid" $valid />
336
  <label for="valid">Enable xHTML Validation</label>
337
 
@@ -350,11 +350,18 @@ class SmartYouTube
350
  </div>
351
  </div>
352
  </div>
353
- <h5 class="author">Another fine plugin by <a href="http://www.prelovac.com/vladimir/">Vladimir Prelovac</a></h5>
354
  END;
355
  }
356
 
357
-
 
 
 
 
 
 
 
358
  function check($the_content, $side = 0)
359
  {
360
  if (strpos($the_content, "httpv") !== false )
@@ -363,26 +370,26 @@ END;
363
  $replacements = array("x", "--");
364
  $the_content = str_replace($char_codes, $replacements, $the_content);
365
 
366
- preg_match_all("/http(v|vh|vhd):\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/watch(\?v\=|\/v\/)([a-zA-Z0-9\-\_]{11})([^<\s]*)/", $the_content, $matches, PREG_SET_ORDER);
367
  foreach ($matches as $match)
368
  {
369
- $the_content = preg_replace("/http".$match[1].":\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/watch(\?v\=|\/v\/)([a-zA-Z0-9\-\_]{11})([^\s<]*)/", $this->tag($match[4], $match[1], $match[5], $side), $the_content, 1);
370
  }
371
 
372
- preg_match_all("/http(vp):\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/view_play_list(\?p\=|\/v\/)([a-zA-Z0-9\-\_]{16})([^<\s]*)/", $the_content, $matches, PREG_SET_ORDER);
373
  foreach ($matches as $match)
374
  {
375
- $the_content = preg_replace("/http".$match[1].":\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/view_play_list(\?p\=|\/v\/)([a-zA-Z0-9\-\_]{16})([^\s<]*)/", $this->tag($match[4], $match[1], $match[5], $side), $the_content, 1);
376
  }
377
  }
378
 
379
  // to work with migrated blogs from Wordpress.com replacing [youtube=youtubeadresss]
380
  if (strpos($the_content, "[youtube") !== false )
381
  {
382
- preg_match_all("/\[youtube\=http:\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/watch(\?v\=|\/v\/)([a-zA-Z0-9\-\_]{11})([^<\s]*)\]/", $the_content, $matches, PREG_SET_ORDER);
383
  foreach ($matches as $match)
384
  {
385
- $the_content = preg_replace("/\[youtube\=http:\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/watch(\?v\=|\/v\/)([a-zA-Z0-9\-\_]{11})([^\s<]*)\]/", $this->tag($match[3], '', $match[4], $side), $the_content, 1);
386
  }
387
  }
388
 
@@ -451,51 +458,27 @@ END;
451
  {
452
  $video_url = htmlspecialchars("$root_url/p/$file&rel=$disp_rel&color1={$this->custom_colors[$disp_color][0]}&color2={$this->custom_colors[$disp_color][1]}&border=$disp_border&fs=1&hl=en&autoplay=$autoplay{$disp_info}$disp_ann&showsearch=$disp_search", ENT_QUOTES) . $high . $time;
453
  $yte_tag = <<<EOT
454
- <!-- Smart Youtube -->
455
- <span class="youtube">
456
- <object type="application/x-shockwave-flash" width="$width" height="$height" data="$video_url" >
457
- <param name="movie" value="$video_url" />
458
- <param name="allowFullScreen" value="true" />
459
- <param name="allowscriptaccess" value="always" />
460
- </object>
461
- </span>
462
- EOT;
463
- }
464
- // This was added to check for iPhone and iPod devices and checks to see if having valid xhtml is on. If valid xhtml is on then the iPhone/iPod will not see the video, so instead we just output the same code that we would if the valid flag was off. This allows us to serve up valid xhtml for our web users and non-valid xhtml to our iPhone/iPod users so they can still enjoy the experience.
465
- elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') || strpos($_SERVER['HTTP_USER_AGENT'], 'iPod') && $valid == 'on')
466
- {
467
- $video_url = htmlspecialchars("$root_url/v/$file&rel=$disp_rel&color1={$this->custom_colors[$disp_color][0]}&color2={$this->custom_colors[$disp_color][1]}&border=$disp_border&fs=1&hl=en&autoplay=$autoplay{$disp_info}$disp_ann&showsearch=$disp_search", ENT_QUOTES) . $high . $time;
468
-
469
- $yte_tag = <<<EOT
470
- <!-- Smart Youtube -->
471
- <span class="youtube">
472
- <object type="application/x-shockwave-flash" width="$width" height="$height" data="$video_url">
473
- <param name="movie" value="$video_url" />
474
- <param name="allowFullScreen" value="true" />
475
- <param name="wmode" value="transparent" />
476
- </object>
477
- </span>
478
  EOT;
479
- }
480
- elseif ($valid == 'off')
481
  {
482
  $video_url = htmlspecialchars("$root_url/v/$file&rel=$disp_rel&color1={$this->custom_colors[$disp_color][0]}&color2={$this->custom_colors[$disp_color][1]}&border=$disp_border&fs=1&hl=en&autoplay=$autoplay{$disp_info}$disp_ann&showsearch=$disp_search", ENT_QUOTES) . $high . $time;
483
  $yte_tag = <<<EOT
484
- <!-- Smart Youtube -->
485
- <span class="youtube">
486
- <object width="$width" height="$height">
487
- <param name="movie" value="$video_url" />
488
- <param name="allowFullScreen" value="true" />
489
- <embed wmode="transparent"
490
- src="$video_url"
491
- type="application/x-shockwave-flash"
492
- allowfullscreen="true"
493
- width="$width"
494
- height="$height">
495
- </embed>
496
- <param name="wmode" value="transparent" />
497
- </object>
498
- </span>
499
  EOT;
500
  }
501
  else
@@ -503,14 +486,13 @@ EOT;
503
  $video_url = htmlspecialchars("$root_url/v/$file&rel=$disp_rel&color1={$this->custom_colors[$disp_color][0]}&color2={$this->custom_colors[$disp_color][1]}&border=$disp_border&fs=1&hl=en&autoplay=$autoplay{$disp_info}$disp_ann&showsearch=$disp_search", ENT_QUOTES) . $high . $time;
504
 
505
  $yte_tag = <<<EOT
506
- <!-- Smart Youtube -->
507
- <span class="youtube">
508
- <object type="application/x-shockwave-flash" width="$width" height="$height" data="$video_url">
509
- <param name="movie" value="$video_url" />
510
- <param name="allowFullScreen" value="true" />
511
- <param name="wmode" value="transparent" />
512
- </object>
513
- </span>
514
  EOT;
515
  }
516
 
@@ -524,12 +506,12 @@ EOT;
524
 
525
  if ($this->options['img'] == 'on')
526
  {
527
- $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>';
528
  }
529
 
530
  if ($this->options['link'] == 'on')
531
  {
532
- $yte_tag.='<a href="http://www.youtube.com/watch?v=' . $file . $high . '">www.youtube.com/watch?v=' . $file . '</a>';
533
  }
534
  // if ($this->options['link'] == 'off' && $this->options['img'] == 'off')
535
  // $yte_tag='http://www.youtube.com/watch?v='.$file;
@@ -564,8 +546,8 @@ EOT;
564
  'heighthq' => 295,
565
  'widthside' => 150,
566
  'heightside' => 125,
567
- 'rel' => 1,
568
- 'color' => 'blank',
569
  'border' => 0,
570
  'link' => 'on',
571
  'valid' => 'off',
@@ -574,7 +556,7 @@ EOT;
574
  'ann' => 'on',
575
  'template' => '{video}',
576
  'autoplay' => 0,
577
- 'privacy' => 0,
578
  'wtext' => '',
579
  'wtitle' => '',
580
  );
105
  $this->options['border'] = !isset($_POST['embedBorder']) ? 0 : 1;
106
  $this->options['color'] = !isset($_POST['embedColor']) ? 'blank' : $_POST['embedColor'];
107
  $this->options['autoplay'] = !isset($_POST['autoplay']) ? 0 : 1;
108
+ $this->options['privacy'] = !isset($_POST['disp_privacy']) ? 0 : 1;
109
 
110
  $this->options['posts'] = !isset($_POST['disp_posts']) ? 'off' : 'on';
111
  $this->options['comments'] = !isset($_POST['disp_comments']) ? 'off' : 'on';
331
  </div>
332
 
333
  <h3>xHTML validation</h3>
334
+ <p class="instruct">Enabling the option below will change default YouTube code to be xHTML valid.</p>
335
  <input id="valid" type="checkbox" name="valid" $valid />
336
  <label for="valid">Enable xHTML Validation</label>
337
 
350
  </div>
351
  </div>
352
  </div>
353
+ <h5 class="author">Another fine WordPress plugin by <a href="http://www.prelovac.com/vladimir/">Vladimir Prelovac</a></h5>
354
  END;
355
  }
356
 
357
+ /**
358
+ * Looks for Smart Youtube URL(s) in the post content
359
+ * and replace them with proper HTML tags
360
+ *
361
+ * @param mixed $the_content
362
+ * @param mixed $side
363
+ * @return mixed
364
+ */
365
  function check($the_content, $side = 0)
366
  {
367
  if (strpos($the_content, "httpv") !== false )
370
  $replacements = array("x", "--");
371
  $the_content = str_replace($char_codes, $replacements, $the_content);
372
 
373
+ preg_match_all("/http(v|vh|vhd):\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/watch(\?v\=|\/v\/|#!v=)([a-zA-Z0-9\-\_]{11})([^<\s]*)/", $the_content, $matches, PREG_SET_ORDER);
374
  foreach ($matches as $match)
375
  {
376
+ $the_content = preg_replace("/http".$match[1].":\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/watch(\?v\=|\/v\/|#!v=)([a-zA-Z0-9\-\_]{11})([^\s<]*)/", $this->tag($match[4], $match[1], $match[5], $side), $the_content, 1);
377
  }
378
 
379
+ preg_match_all("/http(vp):\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/view_play_list(\?p\=|\/v\/|#!v=)([a-zA-Z0-9\-\_]{16})([^<\s]*)/", $the_content, $matches, PREG_SET_ORDER);
380
  foreach ($matches as $match)
381
  {
382
+ $the_content = preg_replace("/http".$match[1].":\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/view_play_list(\?p\=|\/v\/|#!v=)([a-zA-Z0-9\-\_]{16})([^\s<]*)/", $this->tag($match[4], $match[1], $match[5], $side), $the_content, 1);
383
  }
384
  }
385
 
386
  // to work with migrated blogs from Wordpress.com replacing [youtube=youtubeadresss]
387
  if (strpos($the_content, "[youtube") !== false )
388
  {
389
+ preg_match_all("/\[youtube\=http:\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/watch(\?v\=|\/v\/|#!v=)([a-zA-Z0-9\-\_]{11})([^<\s]*)\]/", $the_content, $matches, PREG_SET_ORDER);
390
  foreach ($matches as $match)
391
  {
392
+ $the_content = preg_replace("/\[youtube\=http:\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/watch(\?v\=|\/v\/|#!v=)([a-zA-Z0-9\-\_]{11})([^\s<]*)\]/", $this->tag($match[3], '', $match[4], $side), $the_content, 1);
393
  }
394
  }
395
 
458
  {
459
  $video_url = htmlspecialchars("$root_url/p/$file&rel=$disp_rel&color1={$this->custom_colors[$disp_color][0]}&color2={$this->custom_colors[$disp_color][1]}&border=$disp_border&fs=1&hl=en&autoplay=$autoplay{$disp_info}$disp_ann&showsearch=$disp_search", ENT_QUOTES) . $high . $time;
460
  $yte_tag = <<<EOT
461
+ <span class="youtube">
462
+ <object type="application/x-shockwave-flash" width="$width" height="$height" data="$video_url" >
463
+ <param name="movie" value="$video_url" />
464
+ <param name="allowFullScreen" value="true" />
465
+ <param name="allowscriptaccess" value="always" />
466
+ </object>
467
+ </span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
468
  EOT;
469
+ }
470
+ elseif ($valid == 'off' || strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone')===TRUE || strpos($_SERVER['HTTP_USER_AGENT'], 'iPod')===TRUE)
471
  {
472
  $video_url = htmlspecialchars("$root_url/v/$file&rel=$disp_rel&color1={$this->custom_colors[$disp_color][0]}&color2={$this->custom_colors[$disp_color][1]}&border=$disp_border&fs=1&hl=en&autoplay=$autoplay{$disp_info}$disp_ann&showsearch=$disp_search", ENT_QUOTES) . $high . $time;
473
  $yte_tag = <<<EOT
474
+ <span class="youtube">
475
+ <object width="$width" height="$height">
476
+ <param name="movie" value="$video_url" />
477
+ <param name="allowFullScreen" value="true" />
478
+ <embed wmode="transparent" src="$video_url" type="application/x-shockwave-flash" allowfullscreen="true" width="$width" height="$height"></embed>
479
+ <param name="wmode" value="transparent" />
480
+ </object>
481
+ </span>
 
 
 
 
 
 
 
482
  EOT;
483
  }
484
  else
486
  $video_url = htmlspecialchars("$root_url/v/$file&rel=$disp_rel&color1={$this->custom_colors[$disp_color][0]}&color2={$this->custom_colors[$disp_color][1]}&border=$disp_border&fs=1&hl=en&autoplay=$autoplay{$disp_info}$disp_ann&showsearch=$disp_search", ENT_QUOTES) . $high . $time;
487
 
488
  $yte_tag = <<<EOT
489
+ <span class="youtube">
490
+ <object type="application/x-shockwave-flash" width="$width" height="$height" data="$video_url">
491
+ <param name="movie" value="$video_url" />
492
+ <param name="allowFullScreen" value="true" />
493
+ <param name="wmode" value="transparent" />
494
+ </object>
495
+ </span>
 
496
  EOT;
497
  }
498
 
506
 
507
  if ($this->options['img'] == 'on')
508
  {
509
+ $yte_tag .= '<p><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></p>';
510
  }
511
 
512
  if ($this->options['link'] == 'on')
513
  {
514
+ $yte_tag.='<p><a href="http://www.youtube.com/watch?v=' . $file . $high . '">www.youtube.com/watch?v=' . $file . '</a></p>';
515
  }
516
  // if ($this->options['link'] == 'off' && $this->options['img'] == 'off')
517
  // $yte_tag='http://www.youtube.com/watch?v='.$file;
546
  'heighthq' => 295,
547
  'widthside' => 150,
548
  'heightside' => 125,
549
+ 'rel' => 1,
550
+ 'color' => 'blank',
551
  'border' => 0,
552
  'link' => 'on',
553
  'valid' => 'off',
556
  'ann' => 'on',
557
  'template' => '{video}',
558
  'autoplay' => 0,
559
+ 'privacy' => 0,
560
  'wtext' => '',
561
  'wtitle' => '',
562
  );
smartyoutube.php CHANGED
@@ -4,10 +4,13 @@ Plugin Name: Smart Youtube
4
  Plugin URI: http://www.prelovac.com/vladimir/wordpress-plugins/smart-youtube
5
  Description: Insert YouTube videos in posts, comments and RSS feeds with ease and full customization.
6
  Author: Vladimir Prelovac
7
- Version: 3.4.1
8
  Author URI: http://www.prelovac.com/vladimir/
9
 
10
  Updates:
 
 
 
11
  3.4.1 - Fixed widget
12
  3.4 - Completely rewritten the plugin, added new HD video support, added video privacy option
13
  3.3.2 - Fixed xHTML validation for playlists (credit Dietmar)
4
  Plugin URI: http://www.prelovac.com/vladimir/wordpress-plugins/smart-youtube
5
  Description: Insert YouTube videos in posts, comments and RSS feeds with ease and full customization.
6
  Author: Vladimir Prelovac
7
+ Version: 3.5
8
  Author URI: http://www.prelovac.com/vladimir/
9
 
10
  Updates:
11
+ 3.5 - Fixed Iphone issues
12
+ 3.4.3 - Fixed privacy option
13
+ 3.4.2 - Supports new #! style youtube urls
14
  3.4.1 - Fixed widget
15
  3.4 - Completely rewritten the plugin, added new HD video support, added video privacy option
16
  3.3.2 - Fixed xHTML validation for playlists (credit Dietmar)