Smart YouTube PRO - Version 3.3.2

Version Description

  • Fixed xHTML validation for playlists (credit Dietmar)
Download this release

Release Info

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

Code changes from version 3.3.1 to 3.3.2

Files changed (2) hide show
  1. readme.txt +4 -1
  2. smartyoutube.php +740 -739
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: freediver
3
  Donate link: https://www.networkforgood.org/donation/MakeDonation.aspx?ORGID2=520781390
4
  Tags: youtube, video, play, media, Post, posts, admin
5
  Requires at least: 2.0
6
- Tested up to: 2.9.1
7
  Stable tag: trunk
8
 
9
  Smart Youtube plugin allows you to insert full featured YouTube videos into your post, comments and in RSS feed.
@@ -37,6 +37,9 @@ Plugin by Vladimir Prelovac. Looking for <a href="http://www.prelovac.com/vladim
37
 
38
  == Changelog ==
39
 
 
 
 
40
  = 3.3.1 =
41
  * Fixed Iphone validation (credits to John Neumann)
42
 
3
  Donate link: https://www.networkforgood.org/donation/MakeDonation.aspx?ORGID2=520781390
4
  Tags: youtube, video, play, media, Post, posts, admin
5
  Requires at least: 2.0
6
+ Tested up to: 2.9.2
7
  Stable tag: trunk
8
 
9
  Smart Youtube plugin allows you to insert full featured YouTube videos into your post, comments and in RSS feed.
37
 
38
  == Changelog ==
39
 
40
+ = 3.3.2 =
41
+ * Fixed xHTML validation for playlists (credit Dietmar)
42
+
43
  = 3.3.1 =
44
  * Fixed Iphone validation (credits to John Neumann)
45
 
smartyoutube.php CHANGED
@@ -1,739 +1,740 @@
1
- <?php
2
- /*
3
- 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.3.1
8
- Author URI: http://www.prelovac.com/vladimir/
9
-
10
- Updates:
11
- 3.3.1 - Fixed Iphone validation (credit John Neumann)
12
- 3.3 - Supports migrated blogs from Wordpress.com replacing [youtube=youtubeadresss]
13
- 3.2 - Added title to widget, fixed HTML code issue with widget
14
- 3.1.1 - param closed properly for validation
15
- 3.1 - wmode transparent parameter updated to better handle transparancy
16
- 3.0 - Added video template, option to set sidebar video size, fixed sidebar widget code, fixed video syntax issue
17
- 2.8.1 - Display Annotioans added as option
18
- 2.8 - Support for playlists
19
- 2.7.5 - Plugin url updated to use WP_PLUGIN_URL
20
- 2.7.4 - Added option to remove info&ratings
21
- 2.7.3 - Removed annotiations
22
- 2.7 - Supports a sidebar widget for videos
23
- 2.6 - Added option to remove search button
24
- 2.5 - Added DVD quality support (httpvq)
25
- 2.4.1 - Small fixes in embed and rss links
26
- 2.4 - Added support for extra parameters like &start=50 to start the video at 50th second of play
27
- 2.2 - Full xHTML validaiton
28
- 2.1 - Made the application iPhone compatible and allowed full screen
29
- 2.0 - Support for playback high quality YouTube videos
30
- 1.9 - Added video autoplay option
31
- 1.8 - Solved Problem with HTML validation, enabled full video preview in RSS
32
- 1.6 - Solving a problem with wordpress handling special characters
33
- 1.5 - Added new admin interface and more options to control the video
34
-
35
- To-Doo:
36
- - marinas javascript suggestion for hq videos
37
- - add editor button
38
- - The plugin places a preview image in the RSS feed which is great, but it links to the video on http://www.youtube.com. I would like to change it so the image links to the blog post so I can generate some traffic on my blog.
39
- - localization
40
- - the images appear under the embedded Smart Youtube videos. Is there any way to edit the z-index for Smart Youtube CSS? I
41
- */
42
-
43
- $yte_localversion="2.7.5";
44
-
45
- $CustomColors=array (
46
- "blank" => array("d6d6d6","f0f0f0"),
47
- "storm" => array("3a3a3a","999999"),
48
- "iceberg" => array("2b405b","6b8ab6"),
49
- "acid" => array("006699","54abd6"),
50
- "green" => array("234900","4e9e00"),
51
- "orange" => array("e1600f","febd01"),
52
- "pink" => array("cc2550","e87a9f"),
53
- "purple" => array("402061","9461ca"),
54
- "rubyred" => array("5d1719","cd311b")
55
- );
56
-
57
- $wp_yte_plugin_url = defined('WP_PLUGIN_URL') ? trailingslashit(WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__))) : trailingslashit(get_bloginfo('wpurl')) . PLUGINDIR . '/' . dirname(plugin_basename(__FILE__));
58
-
59
-
60
-
61
-
62
- // Admin Panel
63
- function yte_add_pages()
64
- {
65
- add_options_page('Smart Youtube options', 'Smart Youtube', 8, __FILE__, 'yte_options_page');
66
- }
67
-
68
-
69
-
70
- // Options Page
71
- function yte_options_page()
72
- {
73
- global $yte_localversion;
74
- $status=yte_getinfo();
75
-
76
- $theVersion = $status[1];
77
- $theMessage = $status[3];
78
-
79
-
80
-
81
- if( (version_compare(strval($theVersion), strval($yte_localversion), '>') == 1) )
82
- {
83
- $msg = 'Latest version available '.' <strong>'.$theVersion.'</strong><br />'.$theMessage;
84
- _e('<div id="message" class="updated fade"><p>' . $msg . '</p></div>');
85
-
86
- }
87
-
88
-
89
- // If form was submitted
90
- if (isset($_POST['submitted']))
91
- {
92
- check_admin_referer('smart-youtube');
93
- $disp_img = !isset($_POST['disp_img'])? 'off': 'on';
94
- $disp_link = !isset($_POST['disp_link'])? 'off': 'on';
95
- $disp_search = !isset($_POST['disp_search'])? 'off': 'on';
96
- $disp_ann = !isset($_POST['disp_ann'])? 'off': 'on';
97
- $disp_info = !isset($_POST['disp_info'])? 'off': 'on';
98
- $valid = !isset($_POST['valid'])? 'off': 'on';
99
-
100
- update_option('smart_yt_img', $disp_img);
101
- update_option('smart_yt_link', $disp_link);
102
- update_option('smart_yt_valid', $valid);
103
- update_option('smart_yt_search', $disp_search);
104
- update_option('smart_yt_ann', $disp_ann);
105
- update_option('smart_yt_info', $disp_info);
106
-
107
- $disp_width = (int) ($_POST['disp_width']=="")? '425': $_POST['disp_width'];
108
- $disp_height = (int) ($_POST['disp_height']=="")? '344': $_POST['disp_height'];
109
-
110
- update_option('smart_yt_width', $disp_width);
111
- update_option('smart_yt_height', $disp_height);
112
-
113
- $disp_widthhq = (int) ($_POST['disp_widthhq']=="")? '480': $_POST['disp_widthhq'];
114
- $disp_heighthq = (int) ($_POST['disp_heighthq']=="")? '360': $_POST['disp_heighthq'];
115
-
116
- update_option('smart_yt_widthhq', $disp_widthhq);
117
- update_option('smart_yt_heighthq', $disp_heighthq);
118
-
119
- $disp_widthside = (int) ($_POST['disp_widthside']=="")? '150': $_POST['disp_widthside'];
120
- $disp_heightside = (int) ($_POST['disp_heightside']=="")? '125': $_POST['disp_heightside'];
121
-
122
- update_option('smart_yt_widthside', $disp_widthside);
123
- update_option('smart_yt_heightside', $disp_heightside);
124
-
125
- $disp_rel = !isset($_POST['embedRel'])? '1': $_POST['embedRel'];
126
-
127
- $disp_border = !isset($_POST['embedBorder'])? '0': '1';
128
- $disp_color = !isset($_POST['embedColor'])? 'blank': $_POST['embedColor'];
129
-
130
- $disp_autoplay = !isset($_POST['autoplay'])? '0': '1';
131
-
132
-
133
- update_option('smart_yt_rel', $disp_rel);
134
-
135
- update_option('smart_yt_border', $disp_border);
136
- update_option('smart_yt_color', $disp_color);
137
-
138
- update_option('smart_yt_autoplay', $disp_autoplay);
139
-
140
- $disp_posts = !isset($_POST['disp_posts'])? 'off': 'on';
141
- $disp_comments = !isset($_POST['disp_comments'])? 'off': 'on';
142
-
143
-
144
- update_option('smart_yt_posts', $disp_posts);
145
- update_option('smart_yt_comments', $disp_comments);
146
-
147
- $disp_template = !isset($_POST['disp_template'])? '{video}': stripslashes(htmlspecialchars($_POST['disp_template']));
148
- update_option('smart_yt_template', $disp_template);
149
-
150
-
151
-
152
- $msg_status = 'Smart Youtube options saved.';
153
-
154
- // Show message
155
- _e('<div id="message" class="updated fade"><p>' . $msg_status . '</p></div>');
156
-
157
- }
158
-
159
- // Fetch code from DB
160
- $disp_img = (get_option('smart_yt_img')=='on') ? 'checked':'';
161
- $disp_link = (get_option('smart_yt_link')=='on') ? 'checked':'';
162
- $disp_search = (get_option('smart_yt_search')=='on') ? 'checked':'';
163
- $disp_ann = (get_option('smart_yt_ann')=='on') ? 'checked':'';
164
- $disp_info = (get_option('smart_yt_info')=='on') ? 'checked':'';
165
-
166
- $valid = (get_option('smart_yt_valid')=='on') ? 'checked':'';
167
-
168
-
169
- $disp_width = get_option('smart_yt_width');
170
- $disp_height = get_option('smart_yt_height');
171
-
172
- $disp_widthhq = get_option('smart_yt_widthhq');
173
- $disp_heighthq = get_option('smart_yt_heighthq');
174
-
175
- $disp_widthside = get_option('smart_yt_widthside');
176
- $disp_heightside = get_option('smart_yt_heightside');
177
-
178
- $disp_autoplay = (get_option('smart_yt_autoplay')=='1') ? 'checked':'';
179
-
180
-
181
- $disp_rel = (get_option('smart_yt_rel')=='1') ? 'checked':'';
182
-
183
- $disp_rel2=$disp_rel ? "" : "checked";
184
- $disp_border = (get_option('smart_yt_border')=='1') ? 'checked':'';
185
- $disp_color = get_option('smart_yt_color');
186
-
187
-
188
- $disp_posts = (get_option('smart_yt_posts')=='on') ? 'checked' :'' ;
189
- $disp_comments = (get_option('smart_yt_comments')=='on') ? 'checked':'';
190
-
191
- $disp_template = wp_specialchars(get_option('smart_yt_template'));
192
-
193
-
194
- if ($disp_width=="")
195
- $disp_width="425";
196
- if ($disp_height=="")
197
- $disp_height="355";
198
-
199
-
200
- global $wp_version;
201
- global $wp_yte_plugin_url;
202
- $embed_img=$wp_yte_plugin_url.'/img/embed_selection-vfl29294.png';
203
-
204
- echo '<script src="' . $wp_yte_plugin_url . '/yt.js" type="text/javascript"></script>' . "\n";
205
- echo '<style type="text/css">
206
- #watch-embed-div,
207
- #watch-url-div{
208
- border-top:1px solid #CCC;
209
- font-size:11px;
210
- }
211
- #watch-url-div{
212
- margin:5px 0;
213
- }
214
- #watch-url-field{
215
- font-size:10px;
216
- width:340px;
217
- margin-top:2px;
218
- }
219
- #watch-embed-div label,
220
- #watch-url-div label{
221
- color:#999;
222
- line-height:18px;
223
- font-size:12px;
224
- }
225
- #watch-embed-div input{
226
- font-size:10px;
227
- width:339px;
228
- margin-top:2px;
229
- }
230
- #watch-embed-div #watch-embed-customize{
231
- font-weight:normal;
232
- color:#03c;
233
- }
234
- #watch-customize-embed-div{
235
- display:none;
236
- background-color:white;
237
- border-top:1px solid #CCC;
238
- margin-top:5px;
239
- padding:5px;
240
- }
241
- #watch-customize-embed-form{
242
- display:block;
243
- width:210px;
244
- }
245
- #watch-customize-embed-desc{
246
- display:block;
247
- padding:6px;
248
- }
249
- #watch-customize-embed-theme{
250
- display:block;
251
- clear:both;
252
- }
253
- #watch-customize-embed-theme-swatches{
254
- padding:5px;
255
- display:block;
256
- margin-top:5px;
257
- width:310px;
258
- height:80px;
259
- }
260
- #watch-customize-embed-theme-preview{
261
- display:block;
262
- float:right;
263
- margin:4px 140px;
264
- background:transparent url('.$embed_img.') no-repeat scroll 0px -23px;
265
- width:100px;
266
- height:86px;
267
- }
268
- .watch-image-radio-link{
269
- border:0;
270
- display:inline-block;
271
- float:left;
272
- margin:3px;
273
- }
274
- .watch-image-radio-link:hover{
275
- background-color:#ADD8E6;
276
- }
277
- .watch-image-radio-link.radio_selected{
278
- border:1px solid #000;
279
- margin:2px;
280
- }
281
- .watch-image-radio-link img{
282
- border:1px solid #fff;
283
- background-color:#fff;
284
- padding:0px;
285
- margin:4px;
286
- }
287
- .watch-embed-select{
288
- width:46px;
289
- height:23px;
290
- }
291
- .watch-embed-iceberg{
292
- background:transparent url('.$embed_img.') no-repeat scroll 0px 0px;
293
- }
294
- .watch-embed-blank{
295
- background:transparent url('.$embed_img.') no-repeat scroll -46px 0px;
296
- }
297
- .watch-embed-acid{
298
- background:transparent url('.$embed_img.') no-repeat scroll -92px 0px;
299
- }
300
- .watch-embed-storm{
301
- background:transparent url('.$embed_img.') no-repeat scroll -138px 0px;
302
- }
303
- .watch-embed-green{
304
- background:transparent url('.$embed_img.') no-repeat scroll -184px 0px;
305
- }
306
- .watch-embed-orange{
307
- background:transparent url('.$embed_img.') no-repeat scroll -230px 0px;
308
- }
309
- .watch-embed-pink{
310
- background:transparent url('.$embed_img.') no-repeat scroll -276px 0px;
311
- }
312
- .watch-embed-purple{
313
- background:transparent url('.$embed_img.') no-repeat scroll -322px 0px;
314
- }
315
- .watch-embed-rubyred{
316
- background:transparent url('.$embed_img.') no-repeat scroll -368px 0px;
317
- }
318
- div#dbx-content a{
319
- text-decoration:none;
320
- }
321
- </style>
322
- ';
323
-
324
-
325
-
326
- $imgpath=$wp_yte_plugin_url.'/i';
327
- $actionurl=$_SERVER['REQUEST_URI'];
328
- $nonce=wp_create_nonce( 'smart-youtube');
329
- $example=htmlentities('<div style="float:left;margin-right: 10px;">{video}</div>');
330
- // Configuration Page
331
-
332
-
333
-
334
- echo <<<END
335
- <div class="wrap" style="max-width:950px !important;">
336
- <h2>Smart YouTube</h2>
337
-
338
- <div id="poststuff" style="margin-top:10px;">
339
-
340
- <div id="sideblock" style="float:right;width:220px;margin-left:10px;">
341
- <h2>Information</h2>
342
- <div id="dbx-content" style="text-decoration:none;">
343
- <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 />
344
- <img src="$imgpath/rate.png"><a style="text-decoration:none;" href="http://wordpress.org/extend/plugins/smart-youtube/"> Rate this plugin</a><br /><br />
345
- <img src="$imgpath/help.png"><a style="text-decoration:none;" href="http://www.prelovac.com/vladimir/forum"> Support and Help</a><br />
346
- <p >
347
- <a style="text-decoration:none;" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2567254&lc=US"><img src="$imgpath/paypal.gif"></a>
348
- </p><br />
349
- <img src="$imgpath/more.png"><a style="text-decoration:none;" href="http://www.prelovac.com/vladimir/wordpress-plugins"> Cool WordPress Plugins</a><br /><br />
350
- <img src="$imgpath/twit.png"><a style="text-decoration:none;" href="http://twitter.com/vprelovac"> Follow updates on Twitter</a><br /><br />
351
- <img src="$imgpath/idea.png"><a style="text-decoration:none;" href="http://www.prelovac.com/vladimir/services"> Need a WordPress Expert?</a>
352
- </div>
353
- </div>
354
-
355
- <div id="mainblock" style="width:710px">
356
-
357
- <div class="dbx-content">
358
- <form name="yteform" action="$action_url" method="post">
359
- <input type="hidden" name="submitted" value="1" />
360
- <input type="hidden" id="_wpnonce" name="_wpnonce" value="$nonce" />
361
- <h2>Usage</h2>
362
-
363
- <p>To use the video in your posts, paste YouTube video URL with <strong>httpv://</strong> (notice the 'v'). </p>
364
- <p><strong>Important:</strong> The URL should just be copied into your post normally and the letter 'v' added, do not create a clickable link!</p>
365
- <p>Example: httpv://www.youtube.com/watch?v=OWfksMD4PAg</p>
366
- <p>If you want to embed high quality video (for videos that have them) use httpvh:// instead (Video High).</p>
367
- <p>If you want to embed HD Quality (DVD quality 720p) video use httpvhd:// instead (Video High Defintion).</p>
368
- <p>To embed playlists use httpvp:// (eg. httpvp://www.youtube.com/view_play_list?p=528026B4F7B34094)</p>
369
- <p>Smart Youtube also supports migrated blogs from Wordpress.com using [youtube=youtubeadresss]</p>
370
-
371
- <ul>
372
- <li>httpv:// - regular video</li>
373
- <li>httpvh:// - high quality</li>
374
- <li>httpvhd:// - HD quality</li>
375
- <li>httpvp:// - playlist</li>
376
- </ul>
377
- <h2>Options</h2>
378
- <p> You can adjust the way your embeded youtube videos behave in the options below.</p>
379
- <p><strong>Video settings</strong></p>
380
-
381
- <div><input id="check3" type="checkbox" name="disp_posts" $disp_posts />
382
- <label for="check3">Display videos in posts</label></div>
383
-
384
- <div><input id="check4" type="checkbox" name="disp_comments" $disp_comments />
385
- <label for="check4">Display videos in comments</label></div>
386
-
387
-
388
- <br><br><strong>Video Appearence</strong><br><br>
389
- <p>Video template. Default is just {video}. <br />
390
- You can try $example if you want the text to wrap around video.</p>
391
- <textarea cols="50" id="disp_template" name="disp_template">$disp_template</textarea>
392
-
393
- <p>Video width and height in normal mode. Default is 425x344.</p>
394
- <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>
395
-
396
- <p>Video width and height in <strong>high quality</strong> mode. Default is 480x360.</p>
397
- <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>
398
-
399
- <p>Video width and height in <strong>sidebar</strong> mode (regardless of quality). Default is 150x125.</p>
400
- <input id="disp_widthside" name="disp_widthside" value="$disp_widthside" size="7" />x<input id="disp_heightside" name="disp_heightside" value="$disp_heightside" size="7" /><br><br>
401
-
402
-
403
- <br />
404
- <div id="watch-customize-embed-form">
405
- <input type="radio" $disp_rel id="embedCustomization1" name="embedRel" value="1"/>
406
- <label for="embedCustomization1">Include related videos</label><br/>
407
- <input type="radio" $disp_rel2 id="embedCustomization0" name="embedRel" value="0"/>
408
- <label for="embedCustomization0">Do not include related videos</label><br/>
409
- </div>
410
- <img id="watch-customize-embed-theme-preview" src="$wp_yte_plugin_url/img/preview_embed_blank_sm.gif"/>
411
- <div id="watch-customize-embed-theme-swatches">
412
- <a onclick="onChangeColor('blank'); return false;" class="watch-image-radio-link radio_selected" href="#" id="theme_color_blank_img"><img alt="" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" class="watch-embed-select watch-embed-blank"/></a>
413
- <a onclick="onChangeColor('storm'); return false;" class="watch-image-radio-link" href="#" id="theme_color_storm_img"><img alt="" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" class="watch-embed-select watch-embed-storm"/></a>
414
- <a onclick="onChangeColor('iceberg'); return false;" class="watch-image-radio-link " href="#" id="theme_color_iceberg_img"><img alt="" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" class="watch-embed-select watch-embed-iceberg"/></a>
415
- <a onclick="onChangeColor('acid'); return false;" class="watch-image-radio-link" href="#" id="theme_color_acid_img"><img alt="" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" class="watch-embed-select watch-embed-acid"/></a>
416
- <a onclick="onChangeColor('green'); return false;" class="watch-image-radio-link" href="#" id="theme_color_green_img"><img alt="" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" class="watch-embed-select watch-embed-green"/></a>
417
- <a onclick="onChangeColor('orange'); return false;" class="watch-image-radio-link" href="#" id="theme_color_orange_img"><img alt="" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" class="watch-embed-select watch-embed-orange"/></a>
418
- <a onclick="onChangeColor('pink'); return false;" class="watch-image-radio-link" href="#" id="theme_color_pink_img"><img alt="" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" class="watch-embed-select watch-embed-pink"/></a>
419
- <a onclick="onChangeColor('purple'); return false;" class="watch-image-radio-link" href="#" id="theme_color_purple_img"><img alt="" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" class="watch-embed-select watch-embed-purple"/></a>
420
- <a onclick="onChangeColor('rubyred'); return false;" class="watch-image-radio-link" href="#" id="theme_color_rubyred_img"><img alt="" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" class="watch-embed-select watch-embed-rubyred"/></a>
421
- <input id="embedColor" type="hidden" name="embedColor" value="$disp_color">
422
- <input id="prevUrl" type="hidden" name="prevUrl" value="$wp_yte_plugin_url/img/">
423
- </div>
424
- <div style="margin: 0px 0px 0px 4px; clear: both;">
425
- <input type="checkbox" onchange="onUpdatePreviewImage();" id="show_border_checkbox" name="embedBorder" $disp_border /><label for="show_border_checkbox"> Show Border</label><br>
426
- <input type="checkbox" id="autoplay_checkbox" name="autoplay" $disp_autoplay /><label for="autoplay_checkbox"> Autoplay videos</label><br>
427
- <input type="checkbox" id="disp_search" name="disp_search" $disp_search /><label for="disp_search"> Display search box</label><br>
428
- <input type="checkbox" id="disp_info" name="disp_info" $disp_info /><label for="disp_info"> Remove Titles & Ratings</label><br>
429
- <input type="checkbox" id="disp_ann" name="disp_ann" $disp_ann /><label for="disp_ann"> Remove Annotations</label>
430
- </div>
431
-
432
-
433
- <br>
434
- <p><strong>xHTML validation</strong></p>
435
- <p>Enabling the option below will make your YouTube code xHTML valid. But be warned that code may not work in some browsers like iPhone and in feed readers.</p>
436
- <div><input id="valid" type="checkbox" name="valid" $valid />
437
- <label for="valid">Enable xHTML Validation</label></div>
438
- <br />
439
-
440
-
441
- <br>
442
- <p><strong>RSS feed options</strong></p>
443
- <p>Some RSS feed readers like Bloglines will show embeded YouTube videos. Some will not and Smart YouTube allows you to display a video link and a video screenshot instead.</p>
444
- <p>Smart YouTube will always embed the video but it can not know if the reader supports embeded video or not. So use these additional options at your own likening.</p>
445
-
446
- <div><input id="check2" type="checkbox" name="disp_link" $disp_link />
447
- <label for="check2">Display video link in RSS feed</label></div>
448
-
449
- <div><input id="check1" type="checkbox" name="disp_img" $disp_img />
450
- <label for="check1">Display video preview image in RSS feed</label></div>
451
-
452
- <div class="submit"><input type="submit" name="Submit" value="Update options" /></div>
453
- </form>
454
- </div>
455
-
456
- <br/><br/><h3>&nbsp;</h3>
457
- </div>
458
-
459
- </div>
460
-
461
- <h5>a plugin by <a href="http://www.prelovac.com/vladimir/">Vladimir Prelovac</a></h5>
462
- </div>
463
- END;
464
-
465
- }
466
-
467
- // Add Options Page
468
- add_action('admin_menu', 'yte_add_pages');
469
-
470
-
471
-
472
- function yte_tag($file, $high='v', $time = "", $side = 0) {
473
- global $CustomColors;
474
-
475
-
476
- $playlist=0;
477
-
478
- $disp_rel = get_option('smart_yt_rel');
479
- $disp_border = get_option('smart_yt_border');
480
- $disp_color = get_option('smart_yt_color');
481
- $autoplay = get_option('smart_yt_autoplay');
482
- $disp_search=(get_option('smart_yt_search')=='on') ? "1":"0";
483
- $disp_info=(get_option('smart_yt_info')=='on') ? "&showinfo=0":"";
484
- $disp_ann=(get_option('smart_yt_ann')=='on') ? "&iv_load_policy=3":"";
485
- $template=get_option('smart_yt_template');
486
-
487
-
488
- $valid=get_option('smart_yt_valid');
489
-
490
-
491
- switch ($high)
492
- {
493
- case 'v': $high=""; break;
494
- case 'vh': $high="&amp;ap=%2526fmt%3D18"; break;
495
- case 'vhd': $high="&amp;ap=%2526fmt%3D22"; break;
496
- case 'vp': $high=""; $playlist=1; break;
497
- default : $high=""; break;
498
- }
499
-
500
- $width=$side ? get_option('smart_yt_widthside') : ($high ? get_option('smart_yt_widthhq') : get_option('smart_yt_width'));
501
- $height=$side ? get_option('smart_yt_heightside') : ($high ? get_option('smart_yt_heighthq') : get_option('smart_yt_height'));
502
-
503
-
504
-
505
- if ($width=="")
506
- $width=$high!="" ? "480" : "425" ;
507
- if ($height=="")
508
- $height= $high!="" ? "360" : "344";
509
-
510
-
511
- if ($disp_border)
512
- $height+=18;
513
-
514
-
515
- // if ( strpos($_SERVER['HTTP_USER_AGENT'], "iPhone") || strpos($_SERVER['HTTP_USER_AGENT'], "iPod") )
516
- if ($playlist)
517
- {
518
- $yte_tag = '<!-- Smart Youtube --><span class="youtube"><object width="'.$width.'" height="'.$height.'"><param name="movie" value="'.htmlspecialchars('http://www.youtube.com/p/'.$file.'&rel='.$disp_rel.'&color1='.$CustomColors[$disp_color][0].'&color2='.$CustomColors[$disp_color][1].'&border='.$disp_border.'&fs=1&hl=en&autoplay='.$autoplay.$disp_info.$disp_ann.'&showsearch='.$disp_search, ENT_QUOTES).$high.$time.'" /><param name="allowFullScreen" value="true" /><embed wmode="transparent" src="'.htmlspecialchars('http://www.youtube.com/p/'.$file.'&rel='.$disp_rel.'&color1='.$CustomColors[$disp_color][0].'&color2='.$CustomColors[$disp_color][1].'&border='.$disp_border.'&fs=1&hl=en&autoplay='.$autoplay.$disp_info.$disp_ann.'&showsearch='.$disp_search, ENT_QUOTES).$high.$time.'" type="application/x-shockwave-flash" allowfullscreen="true" width="'.$width.'" height="'.$height.'" ></embed><param name="wmode" value="transparent" /></object></span>';
519
- }
520
- // 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.
521
- elseif (strpos($_SERVER['HTTP_USER_AGENT'], "iPhone") || strpos($_SERVER['HTTP_USER_AGENT'], "iPod") && ($valid=="on")) {
522
- $yte_tag = '<!-- Smart Youtube --><span class="youtube"><object width="'.$width.'" height="'.$height.'"><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&hl=en&autoplay='.$autoplay.$disp_info.$disp_ann.'&showsearch='.$disp_search, ENT_QUOTES).$high.$time.'" /><param name="allowFullScreen" value="true" /><embed wmode="transparent" src="'.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&hl=en&autoplay='.$autoplay.$disp_info.$disp_ann.'&showsearch='.$disp_search, ENT_QUOTES).$high.$time.'" type="application/x-shockwave-flash" allowfullscreen="true" width="'.$width.'" height="'.$height.'" ></embed><param name="wmode" value="transparent" /></object></span>';
523
- }
524
- elseif ($valid=="off") {
525
- $yte_tag = '<!-- Smart Youtube --><span class="youtube"><object width="'.$width.'" height="'.$height.'"><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&hl=en&autoplay='.$autoplay.$disp_info.$disp_ann.'&showsearch='.$disp_search, ENT_QUOTES).$high.$time.'" /><param name="allowFullScreen" value="true" /><embed wmode="transparent" src="'.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&hl=en&autoplay='.$autoplay.$disp_info.$disp_ann.'&showsearch='.$disp_search, ENT_QUOTES).$high.$time.'" type="application/x-shockwave-flash" allowfullscreen="true" width="'.$width.'" height="'.$height.'" ></embed><param name="wmode" value="transparent" /></object></span>';
526
- }
527
- else {
528
- $yte_tag = '<!-- Smart Youtube --><span class="youtube"><object type="application/x-shockwave-flash" width="'.$width.'" height="'.$height.'" 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&hl=en&autoplay='.$autoplay.$disp_info.$disp_ann.'&showsearch='.$disp_search, ENT_QUOTES).$high.$time.'"><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&hl=en&autoplay='.$autoplay.$disp_info.$disp_ann.'&showsearch='.$disp_search, ENT_QUOTES).$high.$time.'" /><param name="allowFullScreen" value="true" /><param name="wmode" value="transparent" /></object></span>';
529
- }
530
-
531
-
532
- if (is_feed())
533
- {
534
- if ($high)
535
- $high="&fmt=18";
536
- if (get_option('smart_yt_img')=='on')
537
- $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>';
538
- if (get_option('smart_yt_link')=='on')
539
- $ytE_tag.='<a href="http://www.youtube.com/watch?v='.$file.$high.'">www.youtube.com/watch?v='.$file.'</a>';
540
- // if ( (get_option('smart_yt_link')=='off') && (get_option('smart_yt_img')=='off') )
541
- // $yte_tag='http://www.youtube.com/watch?v='.$file;
542
- }
543
- $result= str_replace('{video}', $yte_tag, html_entity_decode($template));
544
-
545
- return $result;
546
- }
547
-
548
- function yte_check($the_content, $side=0) {
549
- if(strpos($the_content, "httpv")!==FALSE ) {
550
-
551
- $char_codes = array('&#215;','&#8211;');
552
- $replacements = array("x", "--");
553
- $the_content=str_replace($char_codes, $replacements, $the_content);
554
-
555
- 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);
556
- foreach($matches as $match) {
557
-
558
- $the_content = preg_replace("/http".$match[1].":\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/watch(\?v\=|\/v\/)([a-zA-Z0-9\-\_]{11})([^\s<]*)/", yte_tag($match[4], $match[1], $match[5], $side), $the_content, 1);
559
- }
560
-
561
- 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);
562
- foreach($matches as $match) {
563
- $the_content = preg_replace("/http".$match[1].":\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/view_play_list(\?p\=|\/v\/)([a-zA-Z0-9\-\_]{16})([^\s<]*)/", yte_tag($match[4], $match[1], $match[5], $side), $the_content, 1);
564
- }
565
-
566
-
567
- }
568
-
569
- // to work with migrated blogs from Wordpress.com replacing [youtube=youtubeadresss]
570
- if(strpos($the_content, "[youtube")!==FALSE ) {
571
- 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);
572
- foreach($matches as $match) {
573
- $the_content = preg_replace("/\[youtube\=http:\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/watch(\?v\=|\/v\/)([a-zA-Z0-9\-\_]{11})([^\s<]*)\]/", yte_tag($match[3], '', $match[4], $side), $the_content, 1);
574
- }
575
- }
576
-
577
-
578
- return $the_content;
579
- }
580
-
581
-
582
- function yte_install(){
583
- if(get_option('smart_yt_posts' == '') || !get_option('smart_yt_posts')){
584
- add_option('smart_yt_posts', 'on');
585
- }
586
- if(get_option('smart_yt_width' == '') || !get_option('smart_yt_width')){
587
- add_option('smart_yt_width', '425');
588
- }
589
- if(get_option('smart_yt_height' == '') || !get_option('smart_yt_height')){
590
- add_option('smart_yt_height', '355');
591
- }
592
-
593
- if(get_option('smart_yt_widthhq' == '') || !get_option('smart_yt_widthhq')){
594
- add_option('smart_yt_widthhq', '480');
595
- }
596
- if(get_option('smart_yt_heighthq' == '') || !get_option('smart_yt_heighthq')){
597
- add_option('smart_yt_heighthq', '360');
598
- }
599
-
600
- if(get_option('smart_yt_widthside' == '') || !get_option('smart_yt_widthside')){
601
- add_option('smart_yt_widthside', '150');
602
- }
603
- if(get_option('smart_yt_heightside' == '') || !get_option('smart_yt_heightside')){
604
- add_option('smart_yt_heightside', '125');
605
- }
606
-
607
- if(get_option('smart_yt_rel' == '') || !get_option('smart_yt_rel')){
608
- add_option('smart_yt_rel', '1');
609
- }
610
- if(get_option('smart_yt_color' == '') || !get_option('smart_yt_color')){
611
- add_option('smart_yt_color', 'blank');
612
- }
613
-
614
- if(get_option('smart_yt_link' == '') || !get_option('smart_yt_link')){
615
- add_option('smart_yt_link', 'on');
616
- }
617
-
618
- if(get_option('smart_yt_valid' == '') || !get_option('smart_yt_valid')){
619
- add_option('smart_yt_valid', 'off');
620
- }
621
-
622
- if(get_option('smart_yt_search' == '') || !get_option('smart_yt_search')){
623
- add_option('smart_yt_search', 'off');
624
- }
625
-
626
- if(get_option('smart_yt_info' == '') || !get_option('smart_yt_info')){
627
- add_option('smart_yt_info', 'on');
628
- }
629
-
630
- if(get_option('smart_yt_ann' == '') || !get_option('smart_yt_ann')){
631
- add_option('smart_yt_ann', 'on');
632
- }
633
-
634
- if(get_option('smart_yt_template' == '') || !get_option('smart_yt_template')){
635
- add_option('smart_yt_template', '{video}');
636
- }
637
-
638
-
639
- // register widget
640
- if (function_exists('register_sidebar_widget'))
641
- register_sidebar_widget('Smart YouTube', 'yte_widget');
642
-
643
- if (function_exists('register_widget_control'))
644
- register_widget_control('Smart YouTube', 'yte_widgetcontrol');
645
-
646
-
647
- }
648
-
649
- function yte_widgetcontrol()
650
- {
651
- if ($_REQUEST['submit'])
652
- {
653
- update_option('smart_yt_wtext', stripslashes(($_REQUEST['yte_text'])));
654
- update_option('smart_yt_wtitle', stripslashes(($_REQUEST['yte_title'])));
655
- }
656
- $text=wp_specialchars(get_option('smart_yt_wtext'));
657
- $title=wp_specialchars(get_option('smart_yt_wtitle'));
658
- echo 'Title:<br /><input type="text" id="yte_title" name="yte_title" value="'.$title.'" /><br />';
659
- echo 'Insert HTML code below. In addition to normal text you may use httpv, httpvh and httpvhd links just like in your posts.<br/><textarea id="text" name="yte_text" rows="10" cols="16" class="widefat">'.$text.'</textarea>';
660
- echo '<input type="hidden" id="submit" name="submit" value="1" />';
661
- }
662
-
663
-
664
- function yte_widget($args = array() )
665
- {
666
- extract ($args);
667
- $text = yte_check((get_option('smart_yt_wtext')), 1);
668
- echo $before_widget;
669
- echo $before_title.(get_option('smart_yt_wtitle')).$after_title;
670
- echo $text;
671
- echo $after_widget;
672
-
673
- }
674
-
675
- if (isset($_GET['activate']) && $_GET['activate'] == 'true') {
676
- yte_install();
677
- }
678
-
679
- if (get_option('smart_yt_posts')=='on') {
680
- add_filter('the_content', 'yte_check', 100);
681
- add_filter('the_excerpt','yte_check', 100);
682
-
683
-
684
- }
685
- if (get_option('smart_yt_comments')=='on') {
686
- add_filter('comment_text','yte_check', 100);
687
- }
688
-
689
- add_action( 'plugins_loaded', 'yte_install' );
690
-
691
- add_action( 'after_plugin_row', 'yte_check_plugin_version' );
692
-
693
- function yte_getinfo()
694
- {
695
- $checkfile = "http://svn.wp-plugins.org/smart-youtube/trunk/smartyoutube.chk";
696
- //$checkfile = "http://www.prelovac.com/plugin/smartyoutube.chk";
697
-
698
- $status=array();
699
- return $status;
700
- $vcheck = wp_remote_fopen($checkfile);
701
-
702
- if($vcheck)
703
- {
704
- $version = $yte_localversion;
705
-
706
- $status = explode('@', $vcheck);
707
- return $status;
708
- }
709
- }
710
-
711
- function yte_check_plugin_version($plugin)
712
- {
713
- global $plugindir,$yte_localversion;
714
-
715
- if( strpos($plugin,'smartyoutube.php')!==false )
716
- {
717
-
718
-
719
- $status=yte_getinfo();
720
-
721
- $theVersion = $status[1];
722
- $theMessage = $status[3];
723
-
724
- if( (version_compare(strval($theVersion), strval($yte_localversion), '>') == 1) )
725
- {
726
- $msg = 'Latest version available '.' <strong>'.$theVersion.'</strong><br />'.$theMessage;
727
- echo '<td colspan="5" class="plugin-update" style="line-height:1.2em;">'.$msg.'</td>';
728
- } else {
729
- return;
730
- }
731
-
732
- }
733
- }
734
-
735
-
736
-
737
-
738
-
739
- ?>
 
1
+ <?php
2
+ /*
3
+ 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.3.2
8
+ Author URI: http://www.prelovac.com/vladimir/
9
+
10
+ Updates:
11
+ 3.3.2 - Fixed xHTML validation for playlists (credit Dietmar)
12
+ 3.3.1 - Fixed Iphone validation (credit John Neumann)
13
+ 3.3 - Supports migrated blogs from Wordpress.com replacing [youtube=youtubeadresss]
14
+ 3.2 - Added title to widget, fixed HTML code issue with widget
15
+ 3.1.1 - param closed properly for validation
16
+ 3.1 - wmode transparent parameter updated to better handle transparancy
17
+ 3.0 - Added video template, option to set sidebar video size, fixed sidebar widget code, fixed video syntax issue
18
+ 2.8.1 - Display Annotioans added as option
19
+ 2.8 - Support for playlists
20
+ 2.7.5 - Plugin url updated to use WP_PLUGIN_URL
21
+ 2.7.4 - Added option to remove info&ratings
22
+ 2.7.3 - Removed annotiations
23
+ 2.7 - Supports a sidebar widget for videos
24
+ 2.6 - Added option to remove search button
25
+ 2.5 - Added DVD quality support (httpvq)
26
+ 2.4.1 - Small fixes in embed and rss links
27
+ 2.4 - Added support for extra parameters like &start=50 to start the video at 50th second of play
28
+ 2.2 - Full xHTML validaiton
29
+ 2.1 - Made the application iPhone compatible and allowed full screen
30
+ 2.0 - Support for playback high quality YouTube videos
31
+ 1.9 - Added video autoplay option
32
+ 1.8 - Solved Problem with HTML validation, enabled full video preview in RSS
33
+ 1.6 - Solving a problem with wordpress handling special characters
34
+ 1.5 - Added new admin interface and more options to control the video
35
+
36
+ To-Doo:
37
+ - marinas javascript suggestion for hq videos
38
+ - add editor button
39
+ - The plugin places a preview image in the RSS feed which is great, but it links to the video on http://www.youtube.com. I would like to change it so the image links to the blog post so I can generate some traffic on my blog.
40
+ - localization
41
+ - the images appear under the embedded Smart Youtube videos. Is there any way to edit the z-index for Smart Youtube CSS? I
42
+ */
43
+
44
+ $yte_localversion="2.7.5";
45
+
46
+ $CustomColors=array (
47
+ "blank" => array("d6d6d6","f0f0f0"),
48
+ "storm" => array("3a3a3a","999999"),
49
+ "iceberg" => array("2b405b","6b8ab6"),
50
+ "acid" => array("006699","54abd6"),
51
+ "green" => array("234900","4e9e00"),
52
+ "orange" => array("e1600f","febd01"),
53
+ "pink" => array("cc2550","e87a9f"),
54
+ "purple" => array("402061","9461ca"),
55
+ "rubyred" => array("5d1719","cd311b")
56
+ );
57
+
58
+ $wp_yte_plugin_url = defined('WP_PLUGIN_URL') ? trailingslashit(WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__))) : trailingslashit(get_bloginfo('wpurl')) . PLUGINDIR . '/' . dirname(plugin_basename(__FILE__));
59
+
60
+
61
+
62
+
63
+ // Admin Panel
64
+ function yte_add_pages()
65
+ {
66
+ add_options_page('Smart Youtube options', 'Smart Youtube', 8, __FILE__, 'yte_options_page');
67
+ }
68
+
69
+
70
+
71
+ // Options Page
72
+ function yte_options_page()
73
+ {
74
+ global $yte_localversion;
75
+ $status=yte_getinfo();
76
+
77
+ $theVersion = $status[1];
78
+ $theMessage = $status[3];
79
+
80
+
81
+
82
+ if( (version_compare(strval($theVersion), strval($yte_localversion), '>') == 1) )
83
+ {
84
+ $msg = 'Latest version available '.' <strong>'.$theVersion.'</strong><br />'.$theMessage;
85
+ _e('<div id="message" class="updated fade"><p>' . $msg . '</p></div>');
86
+
87
+ }
88
+
89
+
90
+ // If form was submitted
91
+ if (isset($_POST['submitted']))
92
+ {
93
+ check_admin_referer('smart-youtube');
94
+ $disp_img = !isset($_POST['disp_img'])? 'off': 'on';
95
+ $disp_link = !isset($_POST['disp_link'])? 'off': 'on';
96
+ $disp_search = !isset($_POST['disp_search'])? 'off': 'on';
97
+ $disp_ann = !isset($_POST['disp_ann'])? 'off': 'on';
98
+ $disp_info = !isset($_POST['disp_info'])? 'off': 'on';
99
+ $valid = !isset($_POST['valid'])? 'off': 'on';
100
+
101
+ update_option('smart_yt_img', $disp_img);
102
+ update_option('smart_yt_link', $disp_link);
103
+ update_option('smart_yt_valid', $valid);
104
+ update_option('smart_yt_search', $disp_search);
105
+ update_option('smart_yt_ann', $disp_ann);
106
+ update_option('smart_yt_info', $disp_info);
107
+
108
+ $disp_width = (int) ($_POST['disp_width']=="")? '425': $_POST['disp_width'];
109
+ $disp_height = (int) ($_POST['disp_height']=="")? '344': $_POST['disp_height'];
110
+
111
+ update_option('smart_yt_width', $disp_width);
112
+ update_option('smart_yt_height', $disp_height);
113
+
114
+ $disp_widthhq = (int) ($_POST['disp_widthhq']=="")? '480': $_POST['disp_widthhq'];
115
+ $disp_heighthq = (int) ($_POST['disp_heighthq']=="")? '360': $_POST['disp_heighthq'];
116
+
117
+ update_option('smart_yt_widthhq', $disp_widthhq);
118
+ update_option('smart_yt_heighthq', $disp_heighthq);
119
+
120
+ $disp_widthside = (int) ($_POST['disp_widthside']=="")? '150': $_POST['disp_widthside'];
121
+ $disp_heightside = (int) ($_POST['disp_heightside']=="")? '125': $_POST['disp_heightside'];
122
+
123
+ update_option('smart_yt_widthside', $disp_widthside);
124
+ update_option('smart_yt_heightside', $disp_heightside);
125
+
126
+ $disp_rel = !isset($_POST['embedRel'])? '1': $_POST['embedRel'];
127
+
128
+ $disp_border = !isset($_POST['embedBorder'])? '0': '1';
129
+ $disp_color = !isset($_POST['embedColor'])? 'blank': $_POST['embedColor'];
130
+
131
+ $disp_autoplay = !isset($_POST['autoplay'])? '0': '1';
132
+
133
+
134
+ update_option('smart_yt_rel', $disp_rel);
135
+
136
+ update_option('smart_yt_border', $disp_border);
137
+ update_option('smart_yt_color', $disp_color);
138
+
139
+ update_option('smart_yt_autoplay', $disp_autoplay);
140
+
141
+ $disp_posts = !isset($_POST['disp_posts'])? 'off': 'on';
142
+ $disp_comments = !isset($_POST['disp_comments'])? 'off': 'on';
143
+
144
+
145
+ update_option('smart_yt_posts', $disp_posts);
146
+ update_option('smart_yt_comments', $disp_comments);
147
+
148
+ $disp_template = !isset($_POST['disp_template'])? '{video}': stripslashes(htmlspecialchars($_POST['disp_template']));
149
+ update_option('smart_yt_template', $disp_template);
150
+
151
+
152
+
153
+ $msg_status = 'Smart Youtube options saved.';
154
+
155
+ // Show message
156
+ _e('<div id="message" class="updated fade"><p>' . $msg_status . '</p></div>');
157
+
158
+ }
159
+
160
+ // Fetch code from DB
161
+ $disp_img = (get_option('smart_yt_img')=='on') ? 'checked':'';
162
+ $disp_link = (get_option('smart_yt_link')=='on') ? 'checked':'';
163
+ $disp_search = (get_option('smart_yt_search')=='on') ? 'checked':'';
164
+ $disp_ann = (get_option('smart_yt_ann')=='on') ? 'checked':'';
165
+ $disp_info = (get_option('smart_yt_info')=='on') ? 'checked':'';
166
+
167
+ $valid = (get_option('smart_yt_valid')=='on') ? 'checked':'';
168
+
169
+
170
+ $disp_width = get_option('smart_yt_width');
171
+ $disp_height = get_option('smart_yt_height');
172
+
173
+ $disp_widthhq = get_option('smart_yt_widthhq');
174
+ $disp_heighthq = get_option('smart_yt_heighthq');
175
+
176
+ $disp_widthside = get_option('smart_yt_widthside');
177
+ $disp_heightside = get_option('smart_yt_heightside');
178
+
179
+ $disp_autoplay = (get_option('smart_yt_autoplay')=='1') ? 'checked':'';
180
+
181
+
182
+ $disp_rel = (get_option('smart_yt_rel')=='1') ? 'checked':'';
183
+
184
+ $disp_rel2=$disp_rel ? "" : "checked";
185
+ $disp_border = (get_option('smart_yt_border')=='1') ? 'checked':'';
186
+ $disp_color = get_option('smart_yt_color');
187
+
188
+
189
+ $disp_posts = (get_option('smart_yt_posts')=='on') ? 'checked' :'' ;
190
+ $disp_comments = (get_option('smart_yt_comments')=='on') ? 'checked':'';
191
+
192
+ $disp_template = wp_specialchars(get_option('smart_yt_template'));
193
+
194
+
195
+ if ($disp_width=="")
196
+ $disp_width="425";
197
+ if ($disp_height=="")
198
+ $disp_height="355";
199
+
200
+
201
+ global $wp_version;
202
+ global $wp_yte_plugin_url;
203
+ $embed_img=$wp_yte_plugin_url.'/img/embed_selection-vfl29294.png';
204
+
205
+ echo '<script src="' . $wp_yte_plugin_url . '/yt.js" type="text/javascript"></script>' . "\n";
206
+ echo '<style type="text/css">
207
+ #watch-embed-div,
208
+ #watch-url-div{
209
+ border-top:1px solid #CCC;
210
+ font-size:11px;
211
+ }
212
+ #watch-url-div{
213
+ margin:5px 0;
214
+ }
215
+ #watch-url-field{
216
+ font-size:10px;
217
+ width:340px;
218
+ margin-top:2px;
219
+ }
220
+ #watch-embed-div label,
221
+ #watch-url-div label{
222
+ color:#999;
223
+ line-height:18px;
224
+ font-size:12px;
225
+ }
226
+ #watch-embed-div input{
227
+ font-size:10px;
228
+ width:339px;
229
+ margin-top:2px;
230
+ }
231
+ #watch-embed-div #watch-embed-customize{
232
+ font-weight:normal;
233
+ color:#03c;
234
+ }
235
+ #watch-customize-embed-div{
236
+ display:none;
237
+ background-color:white;
238
+ border-top:1px solid #CCC;
239
+ margin-top:5px;
240
+ padding:5px;
241
+ }
242
+ #watch-customize-embed-form{
243
+ display:block;
244
+ width:210px;
245
+ }
246
+ #watch-customize-embed-desc{
247
+ display:block;
248
+ padding:6px;
249
+ }
250
+ #watch-customize-embed-theme{
251
+ display:block;
252
+ clear:both;
253
+ }
254
+ #watch-customize-embed-theme-swatches{
255
+ padding:5px;
256
+ display:block;
257
+ margin-top:5px;
258
+ width:310px;
259
+ height:80px;
260
+ }
261
+ #watch-customize-embed-theme-preview{
262
+ display:block;
263
+ float:right;
264
+ margin:4px 140px;
265
+ background:transparent url('.$embed_img.') no-repeat scroll 0px -23px;
266
+ width:100px;
267
+ height:86px;
268
+ }
269
+ .watch-image-radio-link{
270
+ border:0;
271
+ display:inline-block;
272
+ float:left;
273
+ margin:3px;
274
+ }
275
+ .watch-image-radio-link:hover{
276
+ background-color:#ADD8E6;
277
+ }
278
+ .watch-image-radio-link.radio_selected{
279
+ border:1px solid #000;
280
+ margin:2px;
281
+ }
282
+ .watch-image-radio-link img{
283
+ border:1px solid #fff;
284
+ background-color:#fff;
285
+ padding:0px;
286
+ margin:4px;
287
+ }
288
+ .watch-embed-select{
289
+ width:46px;
290
+ height:23px;
291
+ }
292
+ .watch-embed-iceberg{
293
+ background:transparent url('.$embed_img.') no-repeat scroll 0px 0px;
294
+ }
295
+ .watch-embed-blank{
296
+ background:transparent url('.$embed_img.') no-repeat scroll -46px 0px;
297
+ }
298
+ .watch-embed-acid{
299
+ background:transparent url('.$embed_img.') no-repeat scroll -92px 0px;
300
+ }
301
+ .watch-embed-storm{
302
+ background:transparent url('.$embed_img.') no-repeat scroll -138px 0px;
303
+ }
304
+ .watch-embed-green{
305
+ background:transparent url('.$embed_img.') no-repeat scroll -184px 0px;
306
+ }
307
+ .watch-embed-orange{
308
+ background:transparent url('.$embed_img.') no-repeat scroll -230px 0px;
309
+ }
310
+ .watch-embed-pink{
311
+ background:transparent url('.$embed_img.') no-repeat scroll -276px 0px;
312
+ }
313
+ .watch-embed-purple{
314
+ background:transparent url('.$embed_img.') no-repeat scroll -322px 0px;
315
+ }
316
+ .watch-embed-rubyred{
317
+ background:transparent url('.$embed_img.') no-repeat scroll -368px 0px;
318
+ }
319
+ div#dbx-content a{
320
+ text-decoration:none;
321
+ }
322
+ </style>
323
+ ';
324
+
325
+
326
+
327
+ $imgpath=$wp_yte_plugin_url.'/i';
328
+ $actionurl=$_SERVER['REQUEST_URI'];
329
+ $nonce=wp_create_nonce( 'smart-youtube');
330
+ $example=htmlentities('<div style="float:left;margin-right: 10px;">{video}</div>');
331
+ // Configuration Page
332
+
333
+
334
+
335
+ echo <<<END
336
+ <div class="wrap" style="max-width:950px !important;">
337
+ <h2>Smart YouTube</h2>
338
+
339
+ <div id="poststuff" style="margin-top:10px;">
340
+
341
+ <div id="sideblock" style="float:right;width:220px;margin-left:10px;">
342
+ <h2>Information</h2>
343
+ <div id="dbx-content" style="text-decoration:none;">
344
+ <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 />
345
+ <img src="$imgpath/rate.png"><a style="text-decoration:none;" href="http://wordpress.org/extend/plugins/smart-youtube/"> Rate this plugin</a><br /><br />
346
+ <img src="$imgpath/help.png"><a style="text-decoration:none;" href="http://www.prelovac.com/vladimir/forum"> Support and Help</a><br />
347
+ <p >
348
+ <a style="text-decoration:none;" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2567254&lc=US"><img src="$imgpath/paypal.gif"></a>
349
+ </p><br />
350
+ <img src="$imgpath/more.png"><a style="text-decoration:none;" href="http://www.prelovac.com/vladimir/wordpress-plugins"> Cool WordPress Plugins</a><br /><br />
351
+ <img src="$imgpath/twit.png"><a style="text-decoration:none;" href="http://twitter.com/vprelovac"> Follow updates on Twitter</a><br /><br />
352
+ <img src="$imgpath/idea.png"><a style="text-decoration:none;" href="http://www.prelovac.com/vladimir/services"> Need a WordPress Expert?</a>
353
+ </div>
354
+ </div>
355
+
356
+ <div id="mainblock" style="width:710px">
357
+
358
+ <div class="dbx-content">
359
+ <form name="yteform" action="$action_url" method="post">
360
+ <input type="hidden" name="submitted" value="1" />
361
+ <input type="hidden" id="_wpnonce" name="_wpnonce" value="$nonce" />
362
+ <h2>Usage</h2>
363
+
364
+ <p>To use the video in your posts, paste YouTube video URL with <strong>httpv://</strong> (notice the 'v'). </p>
365
+ <p><strong>Important:</strong> The URL should just be copied into your post normally and the letter 'v' added, do not create a clickable link!</p>
366
+ <p>Example: httpv://www.youtube.com/watch?v=OWfksMD4PAg</p>
367
+ <p>If you want to embed high quality video (for videos that have them) use httpvh:// instead (Video High).</p>
368
+ <p>If you want to embed HD Quality (DVD quality 720p) video use httpvhd:// instead (Video High Defintion).</p>
369
+ <p>To embed playlists use httpvp:// (eg. httpvp://www.youtube.com/view_play_list?p=528026B4F7B34094)</p>
370
+ <p>Smart Youtube also supports migrated blogs from Wordpress.com using [youtube=youtubeadresss]</p>
371
+
372
+ <ul>
373
+ <li>httpv:// - regular video</li>
374
+ <li>httpvh:// - high quality</li>
375
+ <li>httpvhd:// - HD quality</li>
376
+ <li>httpvp:// - playlist</li>
377
+ </ul>
378
+ <h2>Options</h2>
379
+ <p> You can adjust the way your embeded youtube videos behave in the options below.</p>
380
+ <p><strong>Video settings</strong></p>
381
+
382
+ <div><input id="check3" type="checkbox" name="disp_posts" $disp_posts />
383
+ <label for="check3">Display videos in posts</label></div>
384
+
385
+ <div><input id="check4" type="checkbox" name="disp_comments" $disp_comments />
386
+ <label for="check4">Display videos in comments</label></div>
387
+
388
+
389
+ <br><br><strong>Video Appearence</strong><br><br>
390
+ <p>Video template. Default is just {video}. <br />
391
+ You can try $example if you want the text to wrap around video.</p>
392
+ <textarea cols="50" id="disp_template" name="disp_template">$disp_template</textarea>
393
+
394
+ <p>Video width and height in normal mode. Default is 425x344.</p>
395
+ <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>
396
+
397
+ <p>Video width and height in <strong>high quality</strong> mode. Default is 480x360.</p>
398
+ <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>
399
+
400
+ <p>Video width and height in <strong>sidebar</strong> mode (regardless of quality). Default is 150x125.</p>
401
+ <input id="disp_widthside" name="disp_widthside" value="$disp_widthside" size="7" />x<input id="disp_heightside" name="disp_heightside" value="$disp_heightside" size="7" /><br><br>
402
+
403
+
404
+ <br />
405
+ <div id="watch-customize-embed-form">
406
+ <input type="radio" $disp_rel id="embedCustomization1" name="embedRel" value="1"/>
407
+ <label for="embedCustomization1">Include related videos</label><br/>
408
+ <input type="radio" $disp_rel2 id="embedCustomization0" name="embedRel" value="0"/>
409
+ <label for="embedCustomization0">Do not include related videos</label><br/>
410
+ </div>
411
+ <img id="watch-customize-embed-theme-preview" src="$wp_yte_plugin_url/img/preview_embed_blank_sm.gif"/>
412
+ <div id="watch-customize-embed-theme-swatches">
413
+ <a onclick="onChangeColor('blank'); return false;" class="watch-image-radio-link radio_selected" href="#" id="theme_color_blank_img"><img alt="" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" class="watch-embed-select watch-embed-blank"/></a>
414
+ <a onclick="onChangeColor('storm'); return false;" class="watch-image-radio-link" href="#" id="theme_color_storm_img"><img alt="" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" class="watch-embed-select watch-embed-storm"/></a>
415
+ <a onclick="onChangeColor('iceberg'); return false;" class="watch-image-radio-link " href="#" id="theme_color_iceberg_img"><img alt="" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" class="watch-embed-select watch-embed-iceberg"/></a>
416
+ <a onclick="onChangeColor('acid'); return false;" class="watch-image-radio-link" href="#" id="theme_color_acid_img"><img alt="" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" class="watch-embed-select watch-embed-acid"/></a>
417
+ <a onclick="onChangeColor('green'); return false;" class="watch-image-radio-link" href="#" id="theme_color_green_img"><img alt="" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" class="watch-embed-select watch-embed-green"/></a>
418
+ <a onclick="onChangeColor('orange'); return false;" class="watch-image-radio-link" href="#" id="theme_color_orange_img"><img alt="" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" class="watch-embed-select watch-embed-orange"/></a>
419
+ <a onclick="onChangeColor('pink'); return false;" class="watch-image-radio-link" href="#" id="theme_color_pink_img"><img alt="" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" class="watch-embed-select watch-embed-pink"/></a>
420
+ <a onclick="onChangeColor('purple'); return false;" class="watch-image-radio-link" href="#" id="theme_color_purple_img"><img alt="" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" class="watch-embed-select watch-embed-purple"/></a>
421
+ <a onclick="onChangeColor('rubyred'); return false;" class="watch-image-radio-link" href="#" id="theme_color_rubyred_img"><img alt="" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" class="watch-embed-select watch-embed-rubyred"/></a>
422
+ <input id="embedColor" type="hidden" name="embedColor" value="$disp_color">
423
+ <input id="prevUrl" type="hidden" name="prevUrl" value="$wp_yte_plugin_url/img/">
424
+ </div>
425
+ <div style="margin: 0px 0px 0px 4px; clear: both;">
426
+ <input type="checkbox" onchange="onUpdatePreviewImage();" id="show_border_checkbox" name="embedBorder" $disp_border /><label for="show_border_checkbox"> Show Border</label><br>
427
+ <input type="checkbox" id="autoplay_checkbox" name="autoplay" $disp_autoplay /><label for="autoplay_checkbox"> Autoplay videos</label><br>
428
+ <input type="checkbox" id="disp_search" name="disp_search" $disp_search /><label for="disp_search"> Display search box</label><br>
429
+ <input type="checkbox" id="disp_info" name="disp_info" $disp_info /><label for="disp_info"> Remove Titles & Ratings</label><br>
430
+ <input type="checkbox" id="disp_ann" name="disp_ann" $disp_ann /><label for="disp_ann"> Remove Annotations</label>
431
+ </div>
432
+
433
+
434
+ <br>
435
+ <p><strong>xHTML validation</strong></p>
436
+ <p>Enabling the option below will make your YouTube code xHTML valid. But be warned that code may not work in some browsers like iPhone and in feed readers.</p>
437
+ <div><input id="valid" type="checkbox" name="valid" $valid />
438
+ <label for="valid">Enable xHTML Validation</label></div>
439
+ <br />
440
+
441
+
442
+ <br>
443
+ <p><strong>RSS feed options</strong></p>
444
+ <p>Some RSS feed readers like Bloglines will show embeded YouTube videos. Some will not and Smart YouTube allows you to display a video link and a video screenshot instead.</p>
445
+ <p>Smart YouTube will always embed the video but it can not know if the reader supports embeded video or not. So use these additional options at your own likening.</p>
446
+
447
+ <div><input id="check2" type="checkbox" name="disp_link" $disp_link />
448
+ <label for="check2">Display video link in RSS feed</label></div>
449
+
450
+ <div><input id="check1" type="checkbox" name="disp_img" $disp_img />
451
+ <label for="check1">Display video preview image in RSS feed</label></div>
452
+
453
+ <div class="submit"><input type="submit" name="Submit" value="Update options" /></div>
454
+ </form>
455
+ </div>
456
+
457
+ <br/><br/><h3>&nbsp;</h3>
458
+ </div>
459
+
460
+ </div>
461
+
462
+ <h5>a plugin by <a href="http://www.prelovac.com/vladimir/">Vladimir Prelovac</a></h5>
463
+ </div>
464
+ END;
465
+
466
+ }
467
+
468
+ // Add Options Page
469
+ add_action('admin_menu', 'yte_add_pages');
470
+
471
+
472
+
473
+ function yte_tag($file, $high='v', $time = "", $side = 0) {
474
+ global $CustomColors;
475
+
476
+
477
+ $playlist=0;
478
+
479
+ $disp_rel = get_option('smart_yt_rel');
480
+ $disp_border = get_option('smart_yt_border');
481
+ $disp_color = get_option('smart_yt_color');
482
+ $autoplay = get_option('smart_yt_autoplay');
483
+ $disp_search=(get_option('smart_yt_search')=='on') ? "1":"0";
484
+ $disp_info=(get_option('smart_yt_info')=='on') ? "&showinfo=0":"";
485
+ $disp_ann=(get_option('smart_yt_ann')=='on') ? "&iv_load_policy=3":"";
486
+ $template=get_option('smart_yt_template');
487
+
488
+
489
+ $valid=get_option('smart_yt_valid');
490
+
491
+
492
+ switch ($high)
493
+ {
494
+ case 'v': $high=""; break;
495
+ case 'vh': $high="&amp;ap=%2526fmt%3D18"; break;
496
+ case 'vhd': $high="&amp;ap=%2526fmt%3D22"; break;
497
+ case 'vp': $high=""; $playlist=1; break;
498
+ default : $high=""; break;
499
+ }
500
+
501
+ $width=$side ? get_option('smart_yt_widthside') : ($high ? get_option('smart_yt_widthhq') : get_option('smart_yt_width'));
502
+ $height=$side ? get_option('smart_yt_heightside') : ($high ? get_option('smart_yt_heighthq') : get_option('smart_yt_height'));
503
+
504
+
505
+
506
+ if ($width=="")
507
+ $width=$high!="" ? "480" : "425" ;
508
+ if ($height=="")
509
+ $height= $high!="" ? "360" : "344";
510
+
511
+
512
+ if ($disp_border)
513
+ $height+=18;
514
+
515
+
516
+ // if ( strpos($_SERVER['HTTP_USER_AGENT'], "iPhone") || strpos($_SERVER['HTTP_USER_AGENT'], "iPod") )
517
+ if ($playlist)
518
+ {
519
+ $yte_tag = '<!-- Smart Youtube --><span class="youtube"><object width="'.$width.'" height="'.$height.'" type="application/x-shockwave-flash" data="'.htmlspecialchars('http://www.youtube.com/p/'.$file.'&rel='.$disp_rel.'&color1='.$CustomColors[$disp_color][0].'&color2='.$CustomColors[$disp_color][1].'&border='.$disp_border.'&fs=1&hl=en&autoplay='.$autoplay.$disp_info.$disp_ann.'&showsearch='.$disp_search, ENT_QUOTES).$high.$time.'" ><param name="allowFullScreen" value="true" /><param name="movie" value="'.htmlspecialchars('http://www.youtube.com/p/'.$file.'&rel='.$disp_rel.'&color1='.$CustomColors[$disp_color][0].'&color2='.$CustomColors[$disp_color][1].'&border='.$disp_border.'&fs=1&hl=en&autoplay='.$autoplay.$disp_info.$disp_ann.'&showsearch='.$disp_search, ENT_QUOTES).$high.$time.'" /><param name="allowscriptaccess" value="always" /></object></span>';
520
+ }
521
+ // 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.
522
+ elseif (strpos($_SERVER['HTTP_USER_AGENT'], "iPhone") || strpos($_SERVER['HTTP_USER_AGENT'], "iPod") && ($valid=="on")) {
523
+ $yte_tag = '<!-- Smart Youtube --><span class="youtube"><object width="'.$width.'" height="'.$height.'"><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&hl=en&autoplay='.$autoplay.$disp_info.$disp_ann.'&showsearch='.$disp_search, ENT_QUOTES).$high.$time.'" /><param name="allowFullScreen" value="true" /><embed wmode="transparent" src="'.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&hl=en&autoplay='.$autoplay.$disp_info.$disp_ann.'&showsearch='.$disp_search, ENT_QUOTES).$high.$time.'" type="application/x-shockwave-flash" allowfullscreen="true" width="'.$width.'" height="'.$height.'" ></embed><param name="wmode" value="transparent" /></object></span>';
524
+ }
525
+ elseif ($valid=="off") {
526
+ $yte_tag = '<!-- Smart Youtube --><span class="youtube"><object width="'.$width.'" height="'.$height.'"><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&hl=en&autoplay='.$autoplay.$disp_info.$disp_ann.'&showsearch='.$disp_search, ENT_QUOTES).$high.$time.'" /><param name="allowFullScreen" value="true" /><embed wmode="transparent" src="'.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&hl=en&autoplay='.$autoplay.$disp_info.$disp_ann.'&showsearch='.$disp_search, ENT_QUOTES).$high.$time.'" type="application/x-shockwave-flash" allowfullscreen="true" width="'.$width.'" height="'.$height.'" ></embed><param name="wmode" value="transparent" /></object></span>';
527
+ }
528
+ else {
529
+ $yte_tag = '<!-- Smart Youtube --><span class="youtube"><object type="application/x-shockwave-flash" width="'.$width.'" height="'.$height.'" 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&hl=en&autoplay='.$autoplay.$disp_info.$disp_ann.'&showsearch='.$disp_search, ENT_QUOTES).$high.$time.'"><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&hl=en&autoplay='.$autoplay.$disp_info.$disp_ann.'&showsearch='.$disp_search, ENT_QUOTES).$high.$time.'" /><param name="allowFullScreen" value="true" /><param name="wmode" value="transparent" /></object></span>';
530
+ }
531
+
532
+
533
+ if (is_feed())
534
+ {
535
+ if ($high)
536
+ $high="&fmt=18";
537
+ if (get_option('smart_yt_img')=='on')
538
+ $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>';
539
+ if (get_option('smart_yt_link')=='on')
540
+ $ytE_tag.='<a href="http://www.youtube.com/watch?v='.$file.$high.'">www.youtube.com/watch?v='.$file.'</a>';
541
+ // if ( (get_option('smart_yt_link')=='off') && (get_option('smart_yt_img')=='off') )
542
+ // $yte_tag='http://www.youtube.com/watch?v='.$file;
543
+ }
544
+ $result= str_replace('{video}', $yte_tag, html_entity_decode($template));
545
+
546
+ return $result;
547
+ }
548
+
549
+ function yte_check($the_content, $side=0) {
550
+ if(strpos($the_content, "httpv")!==FALSE ) {
551
+
552
+ $char_codes = array('&#215;','&#8211;');
553
+ $replacements = array("x", "--");
554
+ $the_content=str_replace($char_codes, $replacements, $the_content);
555
+
556
+ 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);
557
+ foreach($matches as $match) {
558
+
559
+ $the_content = preg_replace("/http".$match[1].":\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/watch(\?v\=|\/v\/)([a-zA-Z0-9\-\_]{11})([^\s<]*)/", yte_tag($match[4], $match[1], $match[5], $side), $the_content, 1);
560
+ }
561
+
562
+ 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);
563
+ foreach($matches as $match) {
564
+ $the_content = preg_replace("/http".$match[1].":\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/view_play_list(\?p\=|\/v\/)([a-zA-Z0-9\-\_]{16})([^\s<]*)/", yte_tag($match[4], $match[1], $match[5], $side), $the_content, 1);
565
+ }
566
+
567
+
568
+ }
569
+
570
+ // to work with migrated blogs from Wordpress.com replacing [youtube=youtubeadresss]
571
+ if(strpos($the_content, "[youtube")!==FALSE ) {
572
+ 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);
573
+ foreach($matches as $match) {
574
+ $the_content = preg_replace("/\[youtube\=http:\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/watch(\?v\=|\/v\/)([a-zA-Z0-9\-\_]{11})([^\s<]*)\]/", yte_tag($match[3], '', $match[4], $side), $the_content, 1);
575
+ }
576
+ }
577
+
578
+
579
+ return $the_content;
580
+ }
581
+
582
+
583
+ function yte_install(){
584
+ if(get_option('smart_yt_posts' == '') || !get_option('smart_yt_posts')){
585
+ add_option('smart_yt_posts', 'on');
586
+ }
587
+ if(get_option('smart_yt_width' == '') || !get_option('smart_yt_width')){
588
+ add_option('smart_yt_width', '425');
589
+ }
590
+ if(get_option('smart_yt_height' == '') || !get_option('smart_yt_height')){
591
+ add_option('smart_yt_height', '355');
592
+ }
593
+
594
+ if(get_option('smart_yt_widthhq' == '') || !get_option('smart_yt_widthhq')){
595
+ add_option('smart_yt_widthhq', '480');
596
+ }
597
+ if(get_option('smart_yt_heighthq' == '') || !get_option('smart_yt_heighthq')){
598
+ add_option('smart_yt_heighthq', '360');
599
+ }
600
+
601
+ if(get_option('smart_yt_widthside' == '') || !get_option('smart_yt_widthside')){
602
+ add_option('smart_yt_widthside', '150');
603
+ }
604
+ if(get_option('smart_yt_heightside' == '') || !get_option('smart_yt_heightside')){
605
+ add_option('smart_yt_heightside', '125');
606
+ }
607
+
608
+ if(get_option('smart_yt_rel' == '') || !get_option('smart_yt_rel')){
609
+ add_option('smart_yt_rel', '1');
610
+ }
611
+ if(get_option('smart_yt_color' == '') || !get_option('smart_yt_color')){
612
+ add_option('smart_yt_color', 'blank');
613
+ }
614
+
615
+ if(get_option('smart_yt_link' == '') || !get_option('smart_yt_link')){
616
+ add_option('smart_yt_link', 'on');
617
+ }
618
+
619
+ if(get_option('smart_yt_valid' == '') || !get_option('smart_yt_valid')){
620
+ add_option('smart_yt_valid', 'off');
621
+ }
622
+
623
+ if(get_option('smart_yt_search' == '') || !get_option('smart_yt_search')){
624
+ add_option('smart_yt_search', 'off');
625
+ }
626
+
627
+ if(get_option('smart_yt_info' == '') || !get_option('smart_yt_info')){
628
+ add_option('smart_yt_info', 'on');
629
+ }
630
+
631
+ if(get_option('smart_yt_ann' == '') || !get_option('smart_yt_ann')){
632
+ add_option('smart_yt_ann', 'on');
633
+ }
634
+
635
+ if(get_option('smart_yt_template' == '') || !get_option('smart_yt_template')){
636
+ add_option('smart_yt_template', '{video}');
637
+ }
638
+
639
+
640
+ // register widget
641
+ if (function_exists('register_sidebar_widget'))
642
+ register_sidebar_widget('Smart YouTube', 'yte_widget');
643
+
644
+ if (function_exists('register_widget_control'))
645
+ register_widget_control('Smart YouTube', 'yte_widgetcontrol');
646
+
647
+
648
+ }
649
+
650
+ function yte_widgetcontrol()
651
+ {
652
+ if ($_REQUEST['submit'])
653
+ {
654
+ update_option('smart_yt_wtext', stripslashes(($_REQUEST['yte_text'])));
655
+ update_option('smart_yt_wtitle', stripslashes(($_REQUEST['yte_title'])));
656
+ }
657
+ $text=wp_specialchars(get_option('smart_yt_wtext'));
658
+ $title=wp_specialchars(get_option('smart_yt_wtitle'));
659
+ echo 'Title:<br /><input type="text" id="yte_title" name="yte_title" value="'.$title.'" /><br />';
660
+ echo 'Insert HTML code below. In addition to normal text you may use httpv, httpvh and httpvhd links just like in your posts.<br/><textarea id="text" name="yte_text" rows="10" cols="16" class="widefat">'.$text.'</textarea>';
661
+ echo '<input type="hidden" id="submit" name="submit" value="1" />';
662
+ }
663
+
664
+
665
+ function yte_widget($args = array() )
666
+ {
667
+ extract ($args);
668
+ $text = yte_check((get_option('smart_yt_wtext')), 1);
669
+ echo $before_widget;
670
+ echo $before_title.(get_option('smart_yt_wtitle')).$after_title;
671
+ echo $text;
672
+ echo $after_widget;
673
+
674
+ }
675
+
676
+ if (isset($_GET['activate']) && $_GET['activate'] == 'true') {
677
+ yte_install();
678
+ }
679
+
680
+ if (get_option('smart_yt_posts')=='on') {
681
+ add_filter('the_content', 'yte_check', 100);
682
+ add_filter('the_excerpt','yte_check', 100);
683
+
684
+
685
+ }
686
+ if (get_option('smart_yt_comments')=='on') {
687
+ add_filter('comment_text','yte_check', 100);
688
+ }
689
+
690
+ add_action( 'plugins_loaded', 'yte_install' );
691
+
692
+ add_action( 'after_plugin_row', 'yte_check_plugin_version' );
693
+
694
+ function yte_getinfo()
695
+ {
696
+ $checkfile = "http://svn.wp-plugins.org/smart-youtube/trunk/smartyoutube.chk";
697
+ //$checkfile = "http://www.prelovac.com/plugin/smartyoutube.chk";
698
+
699
+ $status=array();
700
+ return $status;
701
+ $vcheck = wp_remote_fopen($checkfile);
702
+
703
+ if($vcheck)
704
+ {
705
+ $version = $yte_localversion;
706
+
707
+ $status = explode('@', $vcheck);
708
+ return $status;
709
+ }
710
+ }
711
+
712
+ function yte_check_plugin_version($plugin)
713
+ {
714
+ global $plugindir,$yte_localversion;
715
+
716
+ if( strpos($plugin,'smartyoutube.php')!==false )
717
+ {
718
+
719
+
720
+ $status=yte_getinfo();
721
+
722
+ $theVersion = $status[1];
723
+ $theMessage = $status[3];
724
+
725
+ if( (version_compare(strval($theVersion), strval($yte_localversion), '>') == 1) )
726
+ {
727
+ $msg = 'Latest version available '.' <strong>'.$theVersion.'</strong><br />'.$theMessage;
728
+ echo '<td colspan="5" class="plugin-update" style="line-height:1.2em;">'.$msg.'</td>';
729
+ } else {
730
+ return;
731
+ }
732
+
733
+ }
734
+ }
735
+
736
+
737
+
738
+
739
+
740
+ ?>