Smart YouTube PRO - Version 4.1.9

Version Description

  • Fixed HTML validation
  • Colorbox now displayed on archive pages as well
Download this release

Release Info

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

Code changes from version 4.1.8 to 4.1.9

Files changed (2) hide show
  1. readme.txt +5 -1
  2. smartyoutube.php +1564 -1566
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, metacafe, liveleak, vimeo, facebook, thumbnails
5
  Requires at least: 2.0
6
- Tested up to: 3.5
7
  Stable tag: trunk
8
 
9
  Smart Youtube is a professional WordPress Video plugin that allows you to easily insert videos/playlists into your post, comments and in your RSS feed. The plugin is designed to be small and fast and not use any external resources.
@@ -49,6 +49,10 @@ For updates, you can check out [my blog](http://www.prelovac.com/vladimir/) or f
49
 
50
  == Changelog ==
51
 
 
 
 
 
52
  = 4.1.8 =
53
  * 3.5 compatiblity
54
 
3
  Donate link: https://www.networkforgood.org/donation/MakeDonation.aspx?ORGID2=520781390
4
  Tags: youtube, video, play, media, Post, posts, admin, metacafe, liveleak, vimeo, facebook, thumbnails
5
  Requires at least: 2.0
6
+ Tested up to: 3.5.1
7
  Stable tag: trunk
8
 
9
  Smart Youtube is a professional WordPress Video plugin that allows you to easily insert videos/playlists into your post, comments and in your RSS feed. The plugin is designed to be small and fast and not use any external resources.
49
 
50
  == Changelog ==
51
 
52
+ = 4.1.9 =
53
+ * Fixed HTML validation
54
+ * Colorbox now displayed on archive pages as well
55
+
56
  = 4.1.8 =
57
  * 3.5 compatiblity
58
 
smartyoutube.php CHANGED
@@ -1,1566 +1,1564 @@
1
- <?php
2
- /*
3
- Plugin Name: Smart Youtube PRO
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: 4.1.8
8
- Author URI: http://www.prelovac.com/vladimir/
9
-
10
-
11
- To-Do:
12
-
13
- - Is there a way to have smart youtube display multiple thumbnails of youtube videos in this fashion:
14
- http://wordpress.org/extend/plugins/my-youtube-playlist/
15
-
16
- The author of this plugin has done a good job in birthing the concept, but is unable to really do much by way of support or add features, e.g. highlight thumbnail currently playing, flexible grouping styles of thumbnails (horizontal, vertical listing) etc.
17
-
18
- - Wondering if there's a way to have smartyoutube generate a thumbnail of the youtube video that shows up as one of the thumbnail options for the article when someone shares the blog post?
19
-
20
- - Would it be possible to overwrite the global autoplay param in a post, something like httpv://www.youtube.com/watch?v=00000000&autoplay=true; I tried to add autoplay=1 but unfortunately in the resuling html it adds autoplay=0 (the global option) and also autoplay=1
21
- The result is no autoplay :(
22
-
23
- - Instead of editing the shortcut, we have copied from youtube.
24
- I would love to have a button,
25
- like insert Smart YouTube Video
26
- A dialogue box would pop up,
27
- and allow me to just simply paste the link.
28
- Then having check boxes on the side,
29
- which allow me to choose whether you would like HD or not.
30
- thus editing the link correctly.
31
-
32
- I find this would greatly help, especiall when I help create video blogs for community provider who have very little computer background.
33
-
34
- - Please add support for it on the BuddyPress Acitivity page, currently it just shows the url (which won't work because of the httpv and httpvh)
35
-
36
- - Was wondering if it was possible for you to have the plugin take the URL for the Youtube thumbnail for the video and place it into a user defined custom field. The plugin "YoutubeThumb2CustomField" but no longer works in WP 3.0 (network).
37
-
38
- - love to see vimeo support! i have video intensive site...love Vimeo
39
-
40
- Only issue is I would LOVE to add the widget into another sidebar and I do not see this possibility. Can you have multiple Smart YouTubes?
41
-
42
- - 1. Adding few possibilities for posting videos into post � I have great production of videos but before end of 2009 all was in 320 x 240 and after end of 2009 I start publishing video in 640 x 480 resolution. I have adjusted player video for 640 x 480 but now 320 x 240 videos are stretched across all of player window.
43
-
44
- For changes to be easy implemented � I suggest adding 2 or even 3 possibilities for playing videos � like this:
45
- Your original code httpv://www.youtube.com/********************
46
- Another version of httpv#1://www.youtube.com/********************
47
- Another version of httpv#2://www.youtube.com/********************
48
- Another version of httpv#3://www.youtube.com/********************
49
-
50
- Adding #1 after v will allow us to predefine what will be size of player for #1 or number #2 or number #3 � I think it is good idea
51
-
52
- If you don�t put #1, #2, #3 player will be those which is default (without number) � in my case that is 640 x 480.
53
-
54
- 2. If some video is for �personal use� which mean somebody must be log into you tube to see it, than I suggest making possibility for login for authors of those videos � If I put all my materials to be private (up to 25 people can see it) � than I cant publish them trough this way � and allowing authors to write theirs username and password will allow that those vides can be seen on my posts. That way I can protect all my archive of video on youtube, but allow those video can be visible on my blog � which can increase hits, visits and others possibility � that possibility is visible on this plug in http://tubepress.org/ where people can use its username and password for publishing all vides from if they have account on youtube
55
-
56
-
57
- - marinas javascript suggestion for hq videos
58
- - add editor button
59
- - 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.
60
- - localization
61
- - the images appear under the embedded Smart Youtube videos. Is there any way to edit the z-index for Smart Youtube CSS? I
62
- - would like to use multiple instances of the Smart YouTube plugin. I saw the reply that said to simply use multiple calls in one instance of the widget, but that doesn't let me choose different videos for different pages.
63
- - was wondering if it's possible to get a vid and playlist in a custom page template?? Is it possible to add a preview image to search results?
64
- - I wondered if there were a way to bring the video to the forefront layer (perhaps z-index)? I know this actually breaks good design practice in my intended use, but have a look here:
65
- - However, on one page I have two videos and therefore I want to add a a parameter to the second video embed URL to _not_ start automatically. Something like httpv://www.youtube.com/watch?v=xyz123&autostart=off
66
- - Single videos work well from wordpress on the Iphone/ipod. Is there a way to make the playlists work, just getting the ? cube instead of image.
67
- - I would like to "inject" automatically this preview image url in a custom field, in each post, to auto-generate the thumb on my homepage with this image.
68
- */
69
-
70
-
71
-
72
- if (isset($smart_youtube_pro)) return false;
73
-
74
- $smart_youtube_pro = new SmartYouTube_PRO();
75
-
76
- class SmartYouTube_PRO {
77
- var $local_version;
78
- var $plugin_url;
79
- var $options;
80
- var $key;
81
- var $first;
82
- var $first_post_on_archive;
83
-
84
- function SmartYouTube() {
85
- $this->__construct();
86
- }
87
-
88
- function __construct() {
89
- $this->local_version = '1.0'; // TODO: Change this number???
90
-
91
- $this->plugin_url = trailingslashit(plugins_url(null,__FILE__));
92
-
93
-
94
- $this->key = 'smart_youtube_pro';
95
- $this->first_post_on_archive = false;
96
-
97
- $script_path = $this->plugin_url . '/javascripts/jquery.colorbox-min.js';
98
- wp_register_script( 'colorbox', $script_path );
99
-
100
- $this->options = $this->get_options();
101
-
102
- $this->add_filters_and_hooks();
103
- }
104
-
105
- function add_filters_and_hooks() {
106
- if ( $this->options['posts'] == 'on' ) {
107
- add_filter( 'the_content', array( $this, 'check' ), 5 );
108
- add_filter( 'the_excerpt', array( $this, 'check_excerpt' ), 5 );
109
- }
110
-
111
- if ( $this->options['comments'] == 'on' ) {
112
- add_filter( 'comment_text', array( $this, 'check' ), 100 );
113
- }
114
-
115
- add_action( 'plugins_loaded', array( $this, 'install' ) );
116
- add_action( 'admin_menu', array( $this, 'add_menu_items' ) );
117
- add_action( 'admin_head', array( $this, 'plugin_header' ) );
118
- add_action( 'wp_head', array( $this, 'post_header' ) );
119
- add_action( 'wp_print_scripts', array( $this, 'load_scripts' ) );
120
- add_action( 'wp_print_styles', array( $this, 'load_styles' ) );
121
- add_action( 'template_redirect', array( $this, 'mark_first_post_on_archive' ) );
122
-
123
- register_activation_hook(__FILE__, array($this, 'install' ) );
124
- }
125
-
126
- function post_header() {
127
- if ( is_singular() ) {
128
- global $wp_query;
129
- $the_content = $wp_query->post->post_content;
130
- $char_codes = array( '&#215;', '&#8211;' );
131
- $replacements = array( "x", "--" );
132
- $the_content = str_replace( $char_codes, $replacements, $the_content );
133
-
134
- 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 );
135
-
136
- if ( isset( $matches[0][5] ) )
137
- if ( $matches[0][5] != '' )
138
- echo '<meta property="og:image" content="http://i.ytimg.com/vi/' . $matches[0][5] . '/default.jpg" />';
139
-
140
- if ( $this->options['colorbox'] == 'on' ) {
141
- ?>
142
- <script>
143
- jQuery(document).ready(function($){
144
- $(".colorbox_video").colorbox({iframe:true, innerWidth:<?php echo $this->options['width']; ?>, innerHeight:<?php echo $this->options['height']; ?>});
145
- });
146
- </script>
147
- <?php
148
- }
149
- }
150
- }
151
-
152
- function load_scripts() {
153
- if ( $this->options["colorbox"] == 'on' && is_singular() ) {
154
- wp_enqueue_script( 'jquery' );
155
- wp_enqueue_script( 'colorbox' );
156
- }
157
- }
158
-
159
- function load_styles() {
160
- $style_path = $this->plugin_url . '/themes/theme' . $this->options['colorbox_theme'] . '/colorbox.css';
161
- wp_register_style( 'colorbox', $style_path );
162
-
163
- if ( $this->options["colorbox"] == 'on' && is_singular() ) {
164
- wp_enqueue_style( 'colorbox' );
165
- }
166
- }
167
-
168
- function plugin_header() {
169
- if ( ! empty( $_REQUEST['page'] ) )
170
- $page = $_REQUEST['page'];
171
- else
172
- $page = '';
173
- ?>
174
- <style>
175
- <?php if ( ( $page == 'syt_settings' ) || ( $page == 'syt_colorbox_options' ) || ( $page == 'syt_about' ) ) : ?>
176
- #icon-syt_settings { background:transparent url('<?php echo $this->plugin_url .'i/logo.png';?>') no-repeat; }
177
- <?php endif; ?>
178
- </style>
179
- <script>
180
- <?php if ( $page == 'syt_settings' ) : ?>
181
- jQuery(document).ready(function($){
182
- if (($)('#disp_excerpt').val() == 'not')
183
- ($)('#disp_excerpt_align_div').hide();
184
- else
185
- ($)('#disp_excerpt_align_div').show();
186
- ($)('#disp_excerpt').change(function(){
187
- if (($)(this).val() == 'not')
188
- ($)('#disp_excerpt_align_div').hide();
189
- else
190
- ($)('#disp_excerpt_align_div').show();
191
- });
192
- });
193
- <?php endif; ?>
194
- <?php if ( $page == 'syt_colorbox_options' ) : ?>
195
- jQuery(document).ready(function($){
196
- $("#colorbox_theme").change(function() {
197
- var src = $("option:selected", this).val();
198
- if ( src != "" ){
199
- var $imgTag = "<img src=\"" + "<?php echo $this->plugin_url; echo '/screenshots/screenshot-'; ?>" + src + ".jpg\" />";
200
- $("#screenshot_image").empty().html($imgTag).fadeIn();
201
- }
202
- });
203
- });
204
- <?php endif; ?>
205
- </script>
206
- <?php
207
- }
208
-
209
- function add_menu_items() {
210
- $image = $this->plugin_url . '/i/icon.png';
211
- add_menu_page( __( 'Smart Youtube', 'smart-youtube' ), __( 'Smart Youtube', 'smart-youtube' ), 'manage_options', 'syt_settings', array(
212
- &$this,
213
- 'options_page'
214
- ), $image);
215
- $page_settings = add_submenu_page( 'syt_settings', __( 'Smart Youtube', 'smart-youtube' ) . __( ' Settings', 'smart-youtube' ), __( 'Settings', 'smart-youtube' ), 'manage_options', 'syt_settings', array(
216
- &$this,
217
- 'options_page'
218
- ) );
219
- $page_colorbox = add_submenu_page( 'syt_settings', __( 'Smart Youtube', 'smart-youtube' ) . __( ' Colorbox Options', 'smart-youtube' ), __( 'Colorbox Options', 'smart-youtube' ), 'manage_options', 'syt_colorbox_options', array(
220
- &$this,
221
- 'handle_colorbox_options'
222
- ) );
223
- $page_about = add_submenu_page( 'syt_settings', __( 'Smart Youtube', 'smart-youtube' ) . __( ' About', 'smart-youtube' ), __( 'About', 'smart-youtube' ), 'manage_options', 'syt_about', array(
224
- &$this,
225
- 'handle_about'
226
- ) );
227
- }
228
-
229
- function options_page() {
230
- // If form was submitted
231
- if ( isset( $_POST['submitted'] ) ) {
232
- check_admin_referer( 'smart-youtube' );
233
-
234
- $this->options['img'] = ! isset( $_POST['disp_img'] ) ? 'off' : 'on';
235
- $this->options['link'] = ! isset( $_POST['disp_link'] ) ? 'off' : 'on';
236
- $this->options['valid'] = ! isset( $_POST['valid'] ) ? 'off' : 'on';
237
- $this->options['search'] = ! isset( $_POST['disp_search'] ) ? 'off' : 'on';
238
- $this->options['ann'] = ! isset( $_POST['disp_ann'] ) ? 'off' : 'on';
239
-
240
- $this->options['info'] = ! isset( $_POST['disp_info'] ) ? 'off' : 'on';
241
-
242
- $this->options['width'] = ! isset( $_POST['disp_width'] ) ? 425 : intval( $_POST['disp_width'] );
243
- $this->options['height'] = ! isset( $_POST['disp_height'] ) ? 344 : intval( $_POST['disp_height'] );
244
-
245
- $this->options['widthhq'] = ! isset( $_POST['disp_widthhq'] ) ? 480 : intval( $_POST['disp_widthhq'] );
246
- $this->options['heighthq'] = ! isset( $_POST['disp_heighthq'] ) ? 295 : intval( $_POST['disp_heighthq'] );
247
-
248
- $this->options['widthside'] = ! isset( $_POST['disp_widthside'] ) ? 150 : intval( $_POST['disp_widthside'] );
249
- $this->options['heightside'] = ! isset( $_POST['disp_heightside'] ) ? 125 : intval( $_POST['disp_heightside'] );
250
-
251
- $this->options['rel'] = ! isset( $_POST['embedRel'] ) ? 1 : $_POST['embedRel'];
252
- $this->options['autoplay'] = ! isset( $_POST['autoplay'] ) ? 0 : 1;
253
- $this->options['autoplay_first'] = ! isset( $_POST['autoplay_first'] ) ? 0 : 1;
254
- $this->options['privacy'] = ! isset( $_POST['disp_privacy'] ) ? 0 : 1;
255
-
256
- $this->options['posts'] = ! isset( $_POST['disp_posts'] ) ? 'off' : 'on';
257
- $this->options['comments'] = ! isset( $_POST['disp_comments'] ) ? 'off' : 'on';
258
- $this->options['iframe'] = ! isset( $_POST['iframe'] ) ? 'off' : 'on';
259
- $this->options['www'] = ! isset( $_POST['www'] ) ? 'off' : 'on';
260
- $this->options['http'] = ! isset( $_POST['http'] ) ? 'off' : 'on';
261
-
262
- $this->options['template'] = ! isset( $_POST['disp_template'] ) ? '{video}' : stripslashes( htmlspecialchars( $_POST['disp_template'] ) );
263
- $this->options['tag'] = ! isset( $_POST['tag'] ) ? '' : $_POST['tag'];
264
- $this->options['wiziapp'] = ! isset( $_POST['wiziapp'] ) ? 'off' : 'on';
265
- $this->options['loop'] = ! isset( $_POST['loop'] ) ? 0 : 1;
266
- $this->options['thumb'] = ! isset( $_POST['thumb'] ) ? 'off' : 'on';
267
- $this->options['colorbox'] = ! isset( $_POST['colorbox'] ) ? 'off' : 'on';
268
- $this->options['excerpt'] = ! isset( $_POST['excerpt'] ) ? '' : $_POST['excerpt'];
269
- $this->options['excerpt_align'] = ! isset( $_POST['excerpt_align'] ) ? '' : $_POST['excerpt_align'];
270
- $this->options['logoless'] = ! isset( $_POST['logoless'] ) ? 'off' : 'on';
271
- $this->options['theme'] = ! isset( $_POST['theme'] ) ? '' : $_POST['theme'];
272
-
273
- update_option( $this->key, $this->options );
274
-
275
- // Show message
276
- echo '<div id="message" class="updated fade"><p>' . __( 'Smart Youtube options saved.', 'smart-youtube' ) . '</p></div>';
277
- }
278
-
279
- $disp_img = $this->options['img'] == 'on' ? 'checked="checked"' : '';
280
- $disp_link = $this->options['link'] == 'on' ? 'checked="checked"' : '';
281
- $disp_search = $this->options['search'] == 'on' ? 'checked="checked"' : '';
282
- $disp_ann = $this->options['ann'] == 'on' ? 'checked="checked"' : '';
283
- $disp_info = $this->options['info'] == 'on' ? 'checked="checked"' : '';
284
-
285
- $valid = $this->options['valid'] == 'on' ? 'checked="checked"' : '';
286
-
287
- $disp_width = $this->options['width'];
288
- $disp_height = $this->options['height'];
289
-
290
- $disp_widthhq = $this->options['widthhq'];
291
- $disp_heighthq = $this->options['heighthq'];
292
-
293
- $disp_widthside = $this->options['widthside'];
294
- $disp_heightside = $this->options['heightside'];
295
-
296
- $disp_autoplay = $this->options['autoplay'] ? 'checked="checked"' : '';
297
- $disp_autoplay_first = $this->options['autoplay_first'] ? 'checked="checked"' : '';
298
- $disp_rel = $this->options['rel'] ? 'checked="checked"' : '';
299
- $disp_rel2 = $this->options['rel'] ? '' : 'checked="checked"';
300
- $disp_posts = $this->options['posts'] == 'on' ? 'checked="checked"' : '' ;
301
- $disp_comments = $this->options['comments'] == 'on' ? 'checked="checked"' : '';
302
-
303
- $disp_privacy = $this->options['privacy'] ? 'checked="checked"' : '';
304
- $iframe = $this->options['iframe'] =='on' ? 'checked="checked"' : '';
305
- $www = $this->options['www'] =='on' ? 'checked="checked"' : '';
306
- $http = $this->options['http'] =='on' ? 'checked="checked"' : '';
307
- $disp_loop = $this->options['loop'] ? 'checked="checked"' : '';
308
- $thumb = $this->options['thumb'] == 'on' ? 'checked="checked"' : '';
309
- $colorbox = $this->options['colorbox'] == 'on' ? 'checked="checked"' : '';
310
- $excerpt = isset( $this->options['excerpt'] ) ? $this->options['excerpt'] : 'not';
311
- $excerpt_align = isset( $this->options['excerpt_align'] ) ? $this->options['excerpt_align'] : 'left';
312
-
313
- $disp_template = esc_html( $this->options['template'] );
314
- $tag = $this->options['tag'];
315
- $wiziapp = $this->options['wiziapp'] == 'on' ? 'checked="checked"' : '';
316
- $logoless = $this->options['logoless'] == 'on' ? 'checked="checked"' : '';
317
- $theme = isset( $this->options['theme'] ) ? $this->options['theme'] : '';
318
-
319
- if ( ! $disp_width ) {
320
- $disp_width = 425;
321
- }
322
-
323
- if ( ! $disp_height ) {
324
- $disp_height = 344;
325
- }
326
-
327
- global $wp_version;
328
-
329
- $embed_img = $this->plugin_url . '/img/embed_selection-vfl29294.png';
330
-
331
- echo '<script src="' . $this->plugin_url . '/yt.js" type="text/javascript"></script>
332
- <link rel="stylesheet" type="text/css" href="' . $this->plugin_url . '/styleyt.css" />';
333
-
334
- $imgpath = $this->plugin_url.'/i';
335
- $actionurl = stripslashes(htmlentities(strip_tags($_SERVER['REQUEST_URI'])));
336
- $nonce = wp_create_nonce( 'smart-youtube' );
337
- $example = htmlentities( '<div style="float:left;margin-right: 10px;">{video}</div>' );
338
-
339
- // Configuration Page
340
-
341
- ?>
342
- <div class="wrap smartyoutube" >
343
- <?php screen_icon(); ?>
344
- <h2><?php _e( 'Smart YouTube PRO', 'smart-youtube' ); ?></h2>
345
- <a href="admin.php?page=syt_settings"><?php _e( 'Settings', 'smart-youtube' ); ?></a> &nbsp;|&nbsp; <a href="admin.php?page=syt_colorbox_options"><?php _e( 'Colorbox Options', 'smart-youtube' ); ?></a> &nbsp;|&nbsp; <a href="admin.php?page=syt_about"><?php _e( 'About', 'smart-youtube' ); ?></a>
346
- <div id="poststuff" style="margin-top:10px;">
347
- <div id="sideblock" style="float:right;width:270px;margin-left:10px;">
348
- <iframe width=270 height=800 frameborder="0" src="http://www.prelovac.com/plugin/news.php?id=0&utm_source=plugin&utm_medium=plugin&utm_campaign=Smart%2BYoutube"></iframe>
349
- </div>
350
- <div id="mainblock" style="width:710px">
351
- <div class="dbx-content">
352
- <h2 id="usageHeader"><?php _e( 'Usage <span style="font-size:small">[<a href="#">view instructions</a>]</span>', 'smart-youtube' ); ?></h2>
353
- <div id="usage" style="display:none">
354
- <p><?php _e( 'To use the video in your posts, paste YouTube video URL with <strong>httpv://</strong> (notice the \'v\').', 'smart-youtube' ); ?> </p>
355
- <p><?php _e( '<strong>Important:</strong> The URL should just be copied into your post normally and the letter \'v\' added, do not create a clickable link!', 'smart-youtube' ); ?></p>
356
- <p><?php _e( 'Example: httpv://www.youtube.com/watch?v=OWfksMD4PAg', 'smart-youtube' ); ?></p>
357
- <p><?php _e( 'If you want to embed High/HD Quality video use <strong>httpvh://</strong> instead (Video High Defintion).', 'smart-youtube' ); ?></p>
358
- <p><?php _e( 'Vimeo Example: httpv://vimeo.com/27287078', 'smart-youtube' ); ?></p>
359
- <p><?php _e( 'Metacafe Example: httpvh://vww.metacafe.com/watch/7815470/harry_potter_and_the_deathly_hallows_dvd_interview/', 'smart-youtube' ); ?></p>
360
- <p><?php _e( 'Live Leak Example: httpv://www.liveleak.com/view?i=cad_1322822486', 'smart-youtube' ); ?></p>
361
- <p><?php _e( 'To embed playlists use httpvp:// (eg. httpvp://www.youtube.com/playlist?list=PL050E43A49BC5E5E5)', 'smart-youtube' ); ?></p>
362
- <p><?php _e( 'Smart Youtube also supports migrated blogs from Wordpress.com using [youtube=youtubeadresss]', 'smart-youtube' ); ?></p>
363
- <ul>
364
- <li><?php _e( 'httpv:// - regular video', 'smart-youtube' ); ?></li>
365
- <li><?php _e( 'httpvh:// - high/HD quality', 'smart-youtube' ); ?></li>
366
- <li><?php _e( 'httpvp:// - playlist', 'smart-youtube' ); ?></li>
367
- <li><?php _e( 'httpvhp:// - HD playlist', 'smart-youtube' ); ?></li>
368
- <li><?php _e( '[youtube=youtubeadresss] - supported for blogs migrated from wordpress.com', 'smart-youtube' ); ?></li>
369
- </ul>
370
- </div>
371
- <form name="yteform" action="<?php echo $actionurl; ?>" method="post">
372
- <input type="hidden" name="submitted" value="1" />
373
- <input type="hidden" id="_wpnonce" name="_wpnonce" value="<?php echo $nonce; ?>" />
374
- <h2><?php _e( 'Options', 'smart-youtube' ); ?></h2>
375
- <p><?php _e( 'Smart Youtube is powerful and free WordPress plugin for embeding videos into your blog. ', 'smart-youtube' ); ?></p>
376
-
377
- <p><?php _e( 'From the same author: <a href="http://managewp.com" target="_blank">ManageWP.com</a> - Wordpress service that helps you manage all your WordPress sites from one location.', 'smart-youtube' ); ?></p>
378
- <p><?php _e( 'You can adjust the way your embeded youtube videos behave in the options below.', 'smart-youtube' ); ?></p>
379
- <h3><?php _e( 'Video settings', 'smart-youtube' ); ?></h3>
380
- <div>
381
- <input id="check3" type="checkbox" name="disp_posts" <?php echo $disp_posts; ?> />
382
- <label for="check3"><?php _e( 'Display videos in posts', 'smart-youtube' ); ?></label>
383
- </div>
384
- <div>
385
- <input id="check4" type="checkbox" name="disp_comments" <?php echo $disp_comments; ?> />
386
- <label for="check4"><?php _e( 'Display videos in comments', 'smart-youtube' ); ?></label>
387
- </div>
388
- <br />
389
- <div>
390
- <input id="iframe" type="checkbox" name="iframe" <?php echo $iframe; ?> />
391
- <label for="iframe"><?php _e( 'Use IFRAME embed code', 'smart-youtube' ); ?></label> [<a target="_blank" href="http://apiblog.youtube.com/2010/07/new-way-to-embed-youtube-videos.html">?</a>]
392
- </div>
393
- <h3><?php _e( 'Video Appearence', 'smart-youtube' ); ?></h3>
394
- <p class="instruct">
395
- <?php _e( 'Video template. Default is just {video}.', 'smart-youtube' ); ?><br />
396
- <?php echo __( 'You can try <code>', 'smart-youtube' ) . $example . __( '</code> if you want the text to wrap around video.', 'smart-youtube' ); ?>
397
- </p>
398
- <textarea cols="50" id="disp_template" name="disp_template"><?php echo $disp_template; ?></textarea>
399
- <br />
400
- <input id="http" type="checkbox" name="http" <?php echo $http; ?> />
401
- <label for="http"><?php _e( 'Parse links with http:// prefix same as httpv://', 'smart-youtube' ); ?></label>
402
- <br />
403
- <input id="www" type="checkbox" name="www" <?php echo $www; ?> />
404
- <label for="www"><?php _e( 'Parse links without http:// prefix', 'smart-youtube' ); ?></label>
405
- <p class="instruct"><?php _e( 'Video width and height in normal mode (httpv://). Default is 425x344.', 'smart-youtube' ); ?></p>
406
- <div id="inputSizeNormal">
407
- <input class="width" name="disp_width" value="<?php echo $disp_width; ?>" size="7"/>x<input class="height" name="disp_height" value="<?php echo $disp_height; ?>" size="7" />
408
- </div>
409
- <div class="size-chooser" forDiv="inputSizeNormal">
410
- <a v-width="320" v-height="265" href="#">
411
- <span></span>
412
- <div class="outer">
413
- <div></div>
414
- </div>
415
- </a>
416
- <a v-width="425" v-height="344" href="#">
417
- <span></span>
418
- <div class="outer">
419
- <div></div>
420
- </div>
421
- </a>
422
- <a v-width="480" v-height="385" href="#">
423
- <span></span>
424
- <div class="outer">
425
- <div></div>
426
- </div>
427
- </a>
428
- <a v-width="640" v-height="505" href="#">
429
- <span></span>
430
- <div class="outer">
431
- <div></div>
432
- </div>
433
- </a>
434
- <a v-width="960" v-height="745" href="#">
435
- <span></span>
436
- <div class="outer">
437
- <div></div>
438
- </div>
439
- </a>
440
- <br clear="both" />
441
- </div>
442
- <p class="instruct"><?php _e( 'Video width and height in <strong>high quality</strong> mode (httpvh://). Default is 480x295.', 'smart-youtube' ); ?></p>
443
- <div id="inputSizeHQ">
444
- <input class="width" name="disp_widthhq" value="<?php echo $disp_widthhq; ?>" size="7" />x<input class="height" name="disp_heighthq" value="<?php echo $disp_heighthq; ?>" size="7" />
445
- </div>
446
- <div class="size-chooser" forDiv="inputSizeHQ">
447
- <a v-width="480" v-height="295" href="#">
448
- <span></span>
449
- <div class="outer">
450
- <div></div>
451
- </div>
452
- </a>
453
- <a v-width="560" v-height="340" href="#">
454
- <span></span>
455
- <div class="outer">
456
- <div></div>
457
- </div>
458
- </a>
459
- <a v-width="640" v-height="385" href="#">
460
- <span></span>
461
- <div class="outer">
462
- <div></div>
463
- </div>
464
- </a>
465
- <a v-width="853" v-height="505" href="#">
466
- <span></span>
467
- <div class="outer">
468
- <div></div>
469
- </div>
470
- </a>
471
- <a v-width="1280" v-height="745" href="#">
472
- <span></span>
473
- <div class="outer">
474
- <div></div>
475
- </div>
476
- </a>
477
- <br clear="both" />
478
- </div>
479
- <p class="instruct"><?php _e( 'Video width and height in <strong>sidebar</strong> mode (regardless of quality). Default is 150x125.', 'smart-youtube' ); ?></p>
480
- <input id="disp_widthside" name="disp_widthside" value="<?php echo $disp_widthside; ?>" size="7" />x<input id="disp_heightside" name="disp_heightside" value="<?php echo $disp_heightside; ?>" size="7" /><br /><br />
481
- <div id="watch-customize-embed-form">
482
- <input type="radio" <?php echo $disp_rel; ?> id="embedCustomization1" name="embedRel" value="1"/>
483
- <label for="embedCustomization1"><?php _e( 'Include related videos', 'smart-youtube' ); ?></label>
484
- <br/>
485
- <input type="radio" <?php echo $disp_rel2; ?> id="embedCustomization0" name="embedRel" value="0"/>
486
- <label for="embedCustomization0"><?php _e( 'Do not include related videos', 'smart-youtube' ); ?></label>
487
- <br/>
488
- </div>
489
- <br/>
490
- <div style="margin: 0 0 0 4px; clear: both;">
491
- <input type="checkbox" id="autoplay_checkbox" name="autoplay" <?php echo $disp_autoplay; ?> /><label for="autoplay_checkbox"><?php _e( 'Autoplay videos', 'smart-youtube' ); ?></label><br />
492
- <input type="checkbox" id="autoplay_first_checkbox" name="autoplay_first" <?php echo $disp_autoplay_first; ?> /><label for="autoplay_first_checkbox"><?php _e( 'Autoplay only first video on page', 'smart-youtube' ); ?></label><br />
493
- <input type="checkbox" id="loop_checkbox" name="loop" <?php echo $disp_loop; ?> /><label for="loop_checkbox"><?php _e( 'Loop videos', 'smart-youtube' ); ?></label><br />
494
- <input type="checkbox" id="disp_search" name="disp_search" <?php echo $disp_search; ?> /><label for="disp_search"><?php _e( 'Display search box', 'smart-youtube' ); ?></label><br />
495
- <input type="checkbox" id="thumb_checkbox" name="thumb" <?php echo $thumb; ?> /><label for="thumb_checkbox"><?php _e( 'Display thumbnails on home/archive pages', 'smart-youtube' ); ?></label><br />
496
- <input type="checkbox" id="cbox_checkbox" name="colorbox" <?php echo $colorbox; ?> /><label for="cbox_checkbox"><?php _e( 'Show video in colorbox', 'smart-youtube' ); ?></label><br />
497
- <input type="checkbox" id="disp_info" name="disp_info" <?php echo $disp_info; ?> /><label for="disp_info"><?php _e( 'Remove Titles & Ratings', 'smart-youtube' ); ?></label><br />
498
- <input type="checkbox" id="disp_ann" name="disp_ann" <?php echo $disp_ann; ?> /><label for="disp_ann"><?php _e( 'Remove Annotations', 'smart-youtube' ); ?></label><br />
499
- <input type="checkbox" id="logoless" name="logoless" <?php echo $logoless; ?> /><label for="logoless"><?php _e( 'Hide YouTube Logo', 'smart-youtube' ); ?></label><br />
500
- <label for="theme"><?php _e( 'Theme (YouTube only):', 'smart-youtube' ); ?></label>
501
- <select id="theme" name="theme" />
502
- <option value="dark" <?php echo ( ( $theme == 'dark' ) ? 'selected="yes"' : '' ); ?>><?php _e( 'Dark', 'smart-youtube' ); ?></option>
503
- <option value="light" <?php echo ( ( $theme == 'light' ) ? 'selected="yes"' : '' ); ?>><?php _e( 'Light', 'smart-youtube' ); ?></option>
504
- </select><br />
505
- <input type="checkbox" id="privacy" name="disp_privacy" <?php echo $disp_privacy; ?> /><label for="privacy"><?php _e( 'Enable privacy-enhanced mode', 'smart-youtube' ); ?> [<a target="_blank" href="http://www.google.com/support/youtube/bin/answer.py?answer=141046">?</a>] <?php _e( 'videos may not work for Iphone users)', 'smart-youtube' ); ?></label><br />
506
- <div id="disp_excerpt_div">
507
- <label for="disp_excerpt"><?php _e( 'Show embeds in post excerpts as', 'smart-youtube' ); ?></label>
508
- <select id="disp_excerpt" name="excerpt">
509
- <option value="vid" <?php echo ( ( $excerpt == 'vid' ) ? 'selected="yes"' : '' ); ?>><?php _e( 'Video', 'smart-youtube' ); ?></option>
510
- <option value="thm" <?php echo ( ( $excerpt == 'thm' ) ? 'selected="yes"' : '' ); ?>><?php _e( 'Thumbnail', 'smart-youtube' ); ?></option>
511
- <option value="not" <?php echo ( ( $excerpt == 'not' ) ? 'selected="yes"' : '' ); ?>><?php _e( 'Nothing', 'smart-youtube' ); ?></option>
512
- </select>
513
- </div>
514
- <div id="disp_excerpt_align_div">
515
- <label for="disp_excerpt_align"><?php _e( 'Align embeds in post excerpts to', 'smart-youtube' ); ?></label>
516
- <select id="disp_excerpt_align" name="excerpt_align">
517
- <option value="left" <?php echo ( ( $excerpt_align == 'left' ) ? 'selected="yes"' : '' ); ?>><?php _e( 'Left', 'smart-youtube' ); ?></option>
518
- <option value="right" <?php echo ( ( $excerpt_align == 'right' ) ? 'selected="yes"' : '' ); ?>><?php _e( 'Right', 'smart-youtube' ); ?></option>
519
- </select>
520
- </div>
521
- </div>
522
- <h3><?php _e( 'Custom code compatibility', 'smart-youtube' ); ?></h3>
523
- <p><?php _e( 'Use this option if you have used another youtube plugin and switched over to Smart Youtube.', 'smart-youtube' ); ?><p>
524
- <p><?php _e( 'For example if you used [yt]qYWWBwf2wHE[/yt] type of code, you would type yt in the box below.', 'smart-youtube' ); ?></p>
525
- <input id="tag" type="text" name="tag" value="<?php echo $tag; ?>" />
526
- <label for="tag"><?php _e( 'Custom code', 'smart-youtube' ); ?></label>
527
-
528
- <h3><?php _e( 'WiziApp support', 'smart-youtube' ); ?></h3>
529
- <p><?php _e( 'This will integrate your video seamlessly with WiziApp', 'smart-youtube' ); ?></p>
530
- <input id="wiziapp" type="checkbox" name="wiziapp" <?php echo $wiziapp; ?> />
531
- <label for="wiziapp"><?php _e( 'Enable WiziApp support', 'smart-youtube' ); ?></label>
532
- <h3><?php _e( 'xHTML validation', 'smart-youtube' ); ?></h3>
533
- <p class="instruct"><?php _e( 'Enabling the option below will change default YouTube code to be xHTML valid. (videos may not work for Iphone users)', 'smart-youtube' ); ?></p>
534
- <input id="valid" type="checkbox" name="valid" <?php echo $valid; ?> />
535
- <label for="valid"><?php _e( 'Enable xHTML Validation', 'smart-youtube' ); ?></label>
536
- <h3><?php _e( 'RSS feed options', 'smart-youtube' ); ?></h3>
537
- <p class="instruct"><?php _e( '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.', 'smart-youtube' ); ?></p>
538
- <p class="instruct"><?php _e( '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.', 'smart-youtube' ); ?></p>
539
- <input id="check2" type="checkbox" name="disp_link" <?php echo $disp_link; ?> />
540
- <label for="check2"><?php _e( 'Display video link in RSS feed', 'smart-youtube' ); ?></label><br />
541
- <input id="check1" type="checkbox" name="disp_img" <?php echo $disp_img; ?> />
542
- <label for="check1"><?php _e( 'Display video preview image in RSS feed', 'smart-youtube' ); ?></label>
543
- <div class="submit"><input type="submit" name="Submit" value="<?php _e( 'Update options', 'smart-youtube' ); ?>" /></div>
544
- </form>
545
- </div>
546
- </div>
547
- </div>
548
- </div>
549
- <h5 class="author"><?php _e( 'Another fine WordPress plugin by <a href="http://www.prelovac.com/vladimir/">Vladimir Prelovac', 'smart-youtube' ); ?></a></h5>
550
- <?php
551
- }
552
-
553
- function handle_colorbox_options() {
554
- if ( isset( $_POST['submitted'] ) ) {
555
- $this->options['colorbox_theme'] = ( ! isset( $_POST['colorbox_theme'] ) ? '1' : $_POST['colorbox_theme'] );
556
-
557
- update_option( $this->key, $this->options );
558
-
559
- $msg_status = __( 'SEO Friendly Images PRO colorbox options saved.', 'smart-youtube' );
560
-
561
- // Show message
562
- echo '<div id="message" class="updated fade"><p>' . $msg_status . '</p></div>';
563
- }
564
-
565
- $imgpath = $this->plugin_url . '/i';
566
- $actionurl = stripslashes(htmlentities(strip_tags($_SERVER['REQUEST_URI'])));
567
-
568
- $this->options = $this->get_options();
569
- ?>
570
- <div class="wrap">
571
- <?php screen_icon(); ?>
572
- <h2><?php _e( 'Smart YouTube PRO', 'smart-youtube' ); echo '&nbsp;' . $this->local_version; ?></h2>
573
- <a href="admin.php?page=syt_settings"><?php _e( 'Settings', 'smart-youtube' ); ?></a> &nbsp;|&nbsp; <a href="admin.php?page=syt_colorbox_options"><?php _e( 'Colorbox Options', 'smart-youtube' ); ?></a> &nbsp;|&nbsp; <a href="admin.php?page=syt_about"><?php _e( 'About', 'smart-youtube' ); ?></a>
574
- <div id="poststuff" style="margin-top:10px;">
575
- <div id="sideblock" style="float:right;width:270px;margin-left:10px;">
576
- <iframe width=270 height=800 frameborder="0" src="http://www.prelovac.com/plugin/news.php?id=2&utm_source=plugin&utm_medium=plugin&utm_campaign=SEO%2BFriendly%2BImages%2BPRO"></iframe>
577
- </div>
578
- </div>
579
- <div id="mainblock" class="submit">
580
- <div class="dbx-content">
581
- <h2><?php _e( 'Colorbox Options', 'smart-youtube' ); ?></h2>
582
- <br />
583
- <form name="sytform" action="<?php echo $actionurl; ?>" method="post">
584
- <input type="hidden" name="submitted" value="1" />
585
- <div>
586
- <label for="colorbox_theme"><?php _e( 'Choose ColorBox theme:', 'smart-youtube' ); ?></label>
587
- <select id="colorbox_theme" name="colorbox_theme">
588
- <?php for($i = 1; $i <= 11; $i++): ?>
589
- <option value="<?php echo $i; ?>" <?php echo ( $this->options['colorbox_theme'] == $i ) ? 'selected="yes"' : ''; ?>><?php echo __( 'Theme ', 'smart-youtube' ) . $i; ?></option>
590
- <?php endfor; ?>
591
- </select>
592
- </div>
593
- <div>
594
- <label for="screenshot_image"><?php _e( 'Theme screenshot:', 'smart-youtube' ); ?></label>
595
- <div id="screenshot_image">
596
- <img src="<?php echo $this->plugin_url . '/screenshots/screenshot-' . $this->options['colorbox_theme'] . '.jpg'; ?>" />
597
- </div>
598
- </div>
599
- <div style="padding: 1.5em 0;margin: 5px 0;">
600
- <input type="submit" name="Submit" value="<?php _e( 'Update options', 'smart-youtube' ); ?>" />
601
- </div>
602
- </form>
603
- </div>
604
- </div>
605
- <h5><?php _e( 'Another fine WordPress plugin by', 'smart-youtube' ); ?> <a href="http://www.prelovac.com/vladimir/">Vladimir Prelovac</a></h5>
606
- </div>
607
- <?php
608
- }
609
-
610
- function handle_about() {
611
- global $wp_version;
612
-
613
- $upd_msg = "";
614
-
615
- $actionurl = stripslashes(htmlentities(strip_tags($_SERVER['REQUEST_URI'])));
616
- $nonce = wp_create_nonce( 'smart-youtube' );
617
-
618
- $lic_msg = '<p>Welcome to ' . __( 'Smart YouTube PRO', 'smart-youtube' ) . '.</p>';
619
- ?>
620
- <div class="wrap">
621
- <?php screen_icon(); ?>
622
- <h2><?php _e( 'Smart YouTube PRO', 'smart-youtube' ); echo '&nbsp;' . $this->local_version; ?></h2>
623
- <a href="admin.php?page=syt_settings"><?php _e( 'Settings', 'smart-youtube' ); ?></a> &nbsp;|&nbsp; <a href="admin.php?page=syt_colorbox_options"><?php _e( 'Colorbox Options', 'smart-youtube' ); ?></a> &nbsp;|&nbsp; <a href="admin.php?page=syt_about"><?php _e( 'About', 'smart-youtube' ); ?></a>
624
- <div id="poststuff" style="margin-top:10px;">
625
-
626
- <div id="sideblock" style="float:right;width:270px;margin-left:10px;">
627
- <iframe width=270 height=800 frameborder="0" src="http://www.prelovac.com/plugin/news.php?id=2&utm_source=plugin&utm_medium=plugin&utm_campaign=SEO%2BFriendly%2BImages%2BPRO"></iframe>
628
- </div>
629
- </div>
630
- <div id="mainblock" class="submit">
631
- <div class="dbx-content">
632
- <h2><?php _e( 'About', 'smart-youtube' ); ?></h2>
633
- <br />
634
- <form name="STY_about" action="$actionurl" method="post">
635
- <input type="hidden" id="_wpnonce" name="_wpnonce" value="$nonce" />
636
- <input type="hidden" name="submitted" value="1" />
637
- <?php echo $lic_msg; ?>
638
- <?php echo __( 'Version:', 'smart-youtube' ) . $this->local_version; ?> <?php echo $upd_msg; ?>
639
- </form>
640
- </div>
641
- </div>
642
- <h5><?php _e( 'Another fine WordPress plugin by', 'smart-youtube' ); ?> <a href="http://www.prelovac.com/vladimir/">Vladimir Prelovac</a></h5>
643
- </div>
644
- <?php
645
- }
646
-
647
- function mark_first_post_on_archive() {
648
- if ( is_archive() || is_home() || is_front_page() ) {
649
- $this->first_post_on_archive = true;
650
- }
651
- }
652
-
653
- /**
654
- * Looks for Smart Youtube URL(s) in the post content
655
- * and replace them with proper HTML tags
656
- *
657
- * @param mixed $the_content
658
- * @param mixed $side
659
- * @return mixed
660
- */
661
- function check( $the_content, $side = 0 ) {
662
- $char_codes = array( '&#215;', '&#8211;' );
663
- $replacements = array( "x", "--" );
664
- $the_content = str_replace( $char_codes, $replacements, $the_content );
665
- $this->first = false;
666
-
667
- $context = $side ? 'side' : 'post';
668
-
669
- preg_match_all( "/((http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?youtube\.com\/watch(\?v\=|\/v\/|#!v=)([a-zA-Z0-9\-\_]{11})([^<\s]*))|((http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?youtu\.be\/([a-zA-Z0-9\-\_]{11}))|((http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?metacafe\.com\/watch\/([a-zA-Z0-9\-\_]{7})\/([^<^\/\s]*)([\/])?)|((http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?vimeo\.com\/([a-zA-Z0-9\-\_]{8})([\/])?)|((http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?liveleak\.com\/view(\?i\=)([a-zA-Z0-9\-\_]*))|((http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?facebook\.com\/video\/video.php\?v\=([a-zA-Z0-9\-\_]*))|((http(vp|vhp)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?youtube\.com\/(view_play_list\?p\=|playlist\?list\=)([a-zA-Z0-9\-\_]{18,34})([^<\s]*))/", $the_content, $matches, PREG_SET_ORDER );
670
-
671
- foreach ( $matches as $match ) {
672
- if ( $match[1] != '' ) {
673
- if ( 'on' == $this->options['wiziapp'] ) {
674
- $videos = array();
675
- $video_info['src'] = "http://www.youtube.com/watch?v={$match[6]}";
676
- array_push( $videos, $video_info );
677
- $replace_text = '';
678
- $replace_text = apply_filters( 'wiziapp_3rd_party_plugin', $replace_text, 'video', $videos );
679
- $the_content = str_replace( $match[1], $replace_text, $the_content );
680
- } else if ( ( $match[2] == 'http://' && $this->options['http'] == 'on' ) || ( $match[2] == '' && $this->options['www'] == 'on' ) ) {
681
- $the_content = str_replace( $match[1], $this->tag_youtube( $context, $match[6], 'v', $match[7] ), $the_content );
682
- } else if ( $match[3] == 'v' || $match[3] == 'vh' || $match[3] == 'vhd' ) {
683
- $the_content = str_replace( $match[1], $this->tag_youtube( $context, $match[6], $match[3], $match[7] ), $the_content );
684
- }
685
- } elseif ( $match[8] != '' ) {
686
- if ( 'on' == $this->options['wiziapp'] ) {
687
- $videos = array();
688
- $video_info['src'] = "http://www.youtube.com/watch?v={$match[12]}";
689
- array_push( $videos, $video_info );
690
- $replace_text = '';
691
- $replace_text = apply_filters( 'wiziapp_3rd_party_plugin', $replace_text, 'video', $videos );
692
- $the_content = str_replace( $match[1], $replace_text, $the_content );
693
- } else if ( ( $match[9] == 'http://' && $this->options['http'] == 'on' ) || ( $match[9] == '' && $this->options['www'] == 'on' ) ) {
694
- $the_content = str_replace( $match[8], $this->tag_youtube( $context, $match[12], 'v' ), $the_content );
695
- } else if ( $match[10] == 'v' || $match[10] == 'vh' || $match[10] == 'vhd' ) {
696
- $the_content = str_replace( $match[8], $this->tag_youtube( $context, $match[12], $match[10] ), $the_content );
697
- }
698
- } elseif ( $match[13] != '' ) {
699
- if ( 'on' == $this->options['wiziapp'] ) {
700
- $videos = array();
701
- $video_info['src'] = "http://www.metacafe.com/watch/{$match[17]}/{$match[18]}/";
702
- array_push( $videos, $video_info );
703
- $replace_text = '';
704
- $replace_text = apply_filters( 'wiziapp_3rd_party_plugin', $replace_text, 'video', $videos );
705
- $the_content = str_replace( $match[1], $replace_text, $the_content );
706
- } else if ( ( $match[14] == 'http://' && $this->options['http'] == 'on' ) || ( $match[14] == '' && $this->options['www'] == 'on' ) ) {
707
- $the_content = str_replace( $match[13], $this->tag_metacafe( $context, $match[17], 'v', $match[18] ), $the_content );
708
- } else if ( $match[15] == 'v' || $match[15] == 'vh' || $match[15] == 'vhd' ) {
709
- $the_content = str_replace( $match[13], $this->tag_metacafe( $context, $match[17], $match[15], $match[18] ), $the_content );
710
- }
711
- } elseif ( $match[20] != '' ) {
712
- if ( 'on' == $this->options['wiziapp'] ) {
713
- $videos = array();
714
- $video_info['src'] = "http://www.vimeo.com/{$match[24]}";
715
- array_push( $videos, $video_info );
716
- $replace_text = '';
717
- $replace_text = apply_filters( 'wiziapp_3rd_party_plugin', $replace_text, 'video', $videos );
718
- $the_content = str_replace( $match[1], $replace_text, $the_content );
719
- } else if ( ( $match[21] == 'http://' && $this->options['http'] == 'on' ) || ( $match[21] == '' && $this->options['www'] == 'on' ) ) {
720
- $the_content = str_replace( $match[20], $this->tag_vimeo( $context, $match[24], 'v' ), $the_content );
721
- } else if ( $match[22] == 'v' || $match[22] == 'vh' || $match[22] == 'vhd' ) {
722
- $the_content = str_replace( $match[20], $this->tag_vimeo( $context, $match[24], $match[22] ), $the_content );
723
- }
724
- } elseif ( $match[26] != '' ) {
725
- if ( 'on' == $this->options['wiziapp'] ) {
726
- $videos = array();
727
- $video_info['src'] = "http://www.liveleak.com/view?i={$match[31]}";
728
- array_push( $videos, $video_info );
729
- $replace_text = '';
730
- $replace_text = apply_filters( 'wiziapp_3rd_party_plugin', $replace_text, 'video', $videos );
731
- $the_content = str_replace( $match[1], $replace_text, $the_content );
732
- } else if ( ( $match[27] == 'http://' && $this->options['http'] == 'on' ) || ( $match[27] == '' && $this->options['www'] == 'on' ) ) {
733
- $the_content = str_replace( $match[26], $this->tag_liveleak( $context, $match[31], 'v' ), $the_content );
734
- } else if ( $match[28] == 'v' || $match[28] == 'vh' || $match[28] == 'vhd' ) {
735
- $the_content = str_replace( $match[26], $this->tag_liveleak( $context, $match[31], $match[28] ), $the_content );
736
- }
737
- } elseif ( $match[32] != '' ) {
738
- if ( 'on' == $this->options['wiziapp'] ) {
739
- $videos = array();
740
- $video_info['src'] = "http://www.facebook.com/video/video.php?v={$match[36]}";
741
- array_push( $videos, $video_info );
742
- $replace_text = '';
743
- $replace_text = apply_filters( 'wiziapp_3rd_party_plugin', $replace_text, 'video', $videos );
744
- $the_content = str_replace( $match[1], $replace_text, $the_content );
745
- } else if ( ( $match[33] == 'http://' && $this->options['http'] == 'on' ) || ( $match[33] == '' && $this->options['www'] == 'on' ) ) {
746
- $the_content = str_replace( $match[32], $this->tag_facebook( $context, $match[36], 'v' ), $the_content );
747
- } else if ( $match[34] == 'v' || $match[34] == 'vh' || $match[34] == 'vhd' ) {
748
- $the_content = str_replace( $match[32], $this->tag_facebook( $context, $match[36], $match[34] ), $the_content );
749
- }
750
- } elseif ( $match[37] != '' ) {
751
-
752
- if ( 'on' == $this->options['wiziapp'] ) {
753
- $videos = array();
754
- $video_info['src'] = "http://www.youtube.com/playlist?list={$match[42]}";
755
- array_push( $videos, $video_info );
756
- $replace_text = '';
757
- $replace_text = apply_filters( 'wiziapp_3rd_party_plugin', $replace_text, 'video', $videos );
758
- $the_content = str_replace( $match[1], $replace_text, $the_content );
759
- } else if ( ( $match[38] == 'http://' && $this->options['http'] == 'on' ) || ( $match[38] == '' && $this->options['www'] == 'on' ) ) {
760
- $the_content = str_replace( $match[37], $this->tag_youtube( $context, $match[42], 'vp', $match[43] ), $the_content );
761
- } else if ( $match[39] == 'vp' || $match[39] == 'vhp' ) {
762
- $the_content = str_replace( $match[37], $this->tag_youtube( $context, $match[42], $match[39], $match[43] ), $the_content );
763
- }
764
- }
765
- }
766
-
767
- /*preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?youtu\.be\/([a-zA-Z0-9\-\_]{11})/", $the_content, $matches, PREG_SET_ORDER );
768
- foreach ( $matches as $match ) {
769
- if (( $match[1] == 'http://' && $this->options['http'] == 'on' ) || ( $match[1] == '' && $this->options['www'] == 'on' ) ) {
770
- $the_content = str_replace( $match[0], $this->tag_youtube( $context, $match[4], 'v' ), $the_content );
771
- } else if ( $match[2] == 'v' || $match[2] == 'vh' || $match[2] == 'vhd' ) {
772
- $the_content = str_replace( $match[0], $this->tag_youtube( $context, $match[4], $match[2] ), $the_content );
773
- }
774
- }
775
-
776
- preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?metacafe\.com\/watch\/([a-zA-Z0-9\-\_]{7})\/([^<^\/\s]*)([\/])?/", $the_content, $matches, PREG_SET_ORDER );
777
- foreach ( $matches as $match ) {
778
- if ( ( $match[1] == 'http://' && $this->options['http'] == 'on' ) || ( $match[1] == '' && $this->options['www'] == 'on' ) ) {
779
- $the_content = str_replace( $match[0], $this->tag_metacafe( $context, $match[4], 'v', $match[5] ), $the_content );
780
- } else if ( $match[2] == 'v' || $match[2] == 'vh' || $match[2] == 'vhd' ) {
781
- $the_content = str_replace( $match[0], $this->tag_metacafe( $context, $match[4], $match[2], $match[5] ), $the_content );
782
- }
783
- }
784
-
785
- preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?vimeo\.com\/([a-zA-Z0-9\-\_]{8})([\/])?/", $the_content, $matches, PREG_SET_ORDER );
786
- foreach ( $matches as $match ) {
787
- if ( ( $match[1] == 'http://' && $this->options['http'] == 'on' ) || ( $match[1] == '' && $this->options['www'] == 'on' ) ) {
788
- $the_content = str_replace( $match[0], $this->tag_vimeo( $context, $match[4], 'v' ), $the_content );
789
- } else if ( $match[2] == 'v' || $match[2] == 'vh' || $match[2] == 'vhd' ) {
790
- $the_content = str_replace( $match[0], $this->tag_vimeo( $context, $match[4], $match[2] ), $the_content );
791
- }
792
- }
793
-
794
- preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?liveleak\.com\/view(\?i\=)([a-zA-Z0-9\-\_]*)/", $the_content, $matches, PREG_SET_ORDER );
795
- foreach ( $matches as $match ) {
796
- if ( ( $match[1] == 'http://' && $this->options['http'] == 'on' ) || ( $match[1] == '' && $this->options['www'] == 'on' ) ) {
797
- $the_content = str_replace( $match[0], $this->tag_liveleak( $context, $match[5], 'v' ), $the_content );
798
- } else if ( $match[2] == 'v' || $match[2] == 'vh' || $match[2] == 'vhd' ) {
799
- $the_content = str_replace( $match[0], $this->tag_liveleak( $context, $match[5], $match[2] ), $the_content );
800
- }
801
- }
802
-
803
- preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?facebook\.com\/video\/video.php\?v\=([a-zA-Z0-9\-\_]*)/", $the_content, $matches, PREG_SET_ORDER );
804
- foreach ( $matches as $match ) {
805
- if ( ( $match[1] == 'http://' && $this->options['http'] == 'on' ) || ( $match[1] == '' && $this->options['www'] == 'on' ) ) {
806
- $the_content = str_replace( $match[0], $this->tag_facebook( $context, $match[4], 'v' ), $the_content );
807
- } else if ( $match[2] == 'v' || $match[2] == 'vh' || $match[2] == 'vhd' ) {
808
- $the_content = str_replace( $match[0], $this->tag_facebook( $context, $match[4], $match[2] ), $the_content );
809
- }
810
- }
811
-
812
- preg_match_all( "/(http(vp|vhp)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?youtube\.com\/view_play_list(\?p\=|\/v\/|#!v=)([a-zA-Z0-9\-\_]{16})([^<\s]*)/", $the_content, $matches, PREG_SET_ORDER );
813
- foreach ( $matches as $match ) {
814
- if ( ( $match[1] == 'http://' && $this->options['http'] == 'on' ) || ( $match[1] == '' && $this->options['www'] == 'on' ) ) {
815
- $the_content = str_replace( $match[0], $this->tag_youtube( $context, $match[5], 'vp', $match[6] ), $the_content );
816
- } else if ( $match[2] == 'vp' || $match[2] == 'vhp' ) {
817
- $the_content = str_replace( $match[0], $this->tag_youtube( $context, $match[5], $match[2], $match[6] ), $the_content );
818
- }
819
- }*/
820
-
821
- // to work with migrated blogs from Wordpress.com replacing [youtube=youtubeadresss]
822
- if ( strpos($the_content, "[youtube") !== false ) {
823
- 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 );
824
- foreach ( $matches as $match ) {
825
- $the_content = preg_replace( "/\[youtube\=http:\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/watch(\?v\=|\/v\/|#!v=)([a-zA-Z0-9\-\_]{11})([^\s<]*)\]/", $this->tag_youtube( $context, $match[3], '', $match[4] ), $the_content, 1 );
826
- }
827
- }
828
- $tag = $this->options['tag'];
829
-
830
- if ( $tag != '' && strpos( $the_content, "[".$tag."]" ) !== false ) {
831
- preg_match_all( "/\[$tag\]([a-zA-Z0-9\-\_]{11})([^<\s]*)\[\/$tag\]/", $the_content, $matches, PREG_SET_ORDER );
832
- foreach ( $matches as $match ) {
833
- $the_content = preg_replace( "/\[$tag\]([a-zA-Z0-9\-\_]{11})([^<\s]*)\[\/$tag\]/", $this->tag_youtube( $context, $match[1], '', '' ), $the_content, 1 );
834
- }
835
- }
836
-
837
- if ( $this->first_post_on_archive ) {
838
- $this->first_post_on_archive = false;
839
- }
840
-
841
- return $the_content;
842
- }
843
-
844
- function check_excerpt( $the_content ) {
845
- $excerpt = $this->options['excerpt'];
846
- $template = trim($this->options['template']) == '' ? '{video}' : $this->options['template'];
847
-
848
- if ( $excerpt != 'not' ) {
849
- global $post;
850
- $content = $post->post_content;
851
-
852
- preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?youtube\.com\/watch(\?v\=|\/v\/|#!v=)([a-zA-Z0-9\-\_]{11})([^<\s]*)/", $content, $matches['youtube.com'], PREG_SET_ORDER );
853
- preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?youtu\.be\/([a-zA-Z0-9\-\_]{11})/", $content, $matches['youtu.be'], PREG_SET_ORDER );
854
- preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?metacafe\.com\/watch\/([a-zA-Z0-9\-\_]{7})\/([^<^\/\s]*)([\/])?/", $content, $matches['metacafe.com'], PREG_SET_ORDER );
855
- preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?vimeo\.com\/([a-zA-Z0-9\-\_]{8})([\/])?/", $content, $matches['vimeo.com'], PREG_SET_ORDER );
856
- preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?liveleak\.com\/view(\?i\=)([a-zA-Z0-9\-\_]*)/", $content, $matches['liveleak.com'], PREG_SET_ORDER );
857
- preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?facebook\.com\/video\/video.php\?v\=([a-zA-Z0-9\-\_]*)/", $content, $matches['facebook.com'], PREG_SET_ORDER );
858
-
859
- if ( isset( $matches['youtube.com'][0] ) ) {
860
- if ( ( $matches['youtube.com'][0][1] == 'http://' && $this->options['http'] == 'on' ) || ( $matches['youtube.com'][0][1] == '' && $this->options['www'] == 'on' ) ) {
861
- $matches['youtube.com'][0][0] = str_replace( $matches['youtube.com'][0][0], $this->tag_youtube( 'excerpt', $matches['youtube.com'][0][5], 'v', $matches['youtube.com'][0][6] ), $matches['youtube.com'][0][0] );
862
- } else if ( $matches['youtube.com'][0][2] == 'v' || $matches['youtube.com'][0][2] == 'vh' || $matches['youtube.com'][0][2] == 'vhd' ) {
863
- $matches['youtube.com'][0][0] = str_replace( $matches['youtube.com'][0][0], $this->tag_youtube( 'excerpt', $matches['youtube.com'][0][5], $matches['youtube.com'][0][2], $matches['youtube.com'][0][6] ), $matches['youtube.com'][0][0] );
864
- }
865
- $result = $matches['youtube.com'][0][0];
866
- } else if ( isset( $matches['youtu.be'][0] ) ) {
867
- if ( ( $matches['youtu.be'][0][1] == 'http://' && $this->options['http'] == 'on' ) || ( $matches['youtu.be'][0][1] == '' && $this->options['www'] == 'on' ) ) {
868
- $matches['youtu.be'][0][0] = str_replace( $matches['youtu.be'][0][0], $this->tag_youtube( 'excerpt', $matches['youtu.be'][0][4], 'v' ), $matches['youtu.be'][0][0] );
869
- } else if ( $matches['youtu.be'][0][2] == 'v' || $matches['youtu.be'][0][2] == 'vh' || $matches['youtu.be'][0][2] == 'vhd' ) {
870
- $matches['youtu.be'][0][0] = str_replace( $matches['youtu.be'][0][0], $this->tag_youtube( 'excerpt', $matches['youtu.be'][0][4], $matches['youtu.be'][0][2]), $matches['youtu.be'][0][0] );
871
- }
872
- $result = $matches['youtu.be'][0][0];
873
- } else if ( isset( $matches['metacafe.com'][0] ) ) {
874
- if ( ( $matches['metacafe.com'][0][1] == 'http://' && $this->options['http'] == 'on' ) || ( $matches['metacafe.com'][0][1] == '' && $this->options['www'] == 'on' ) ) {
875
- $matches['metacafe.com'][0][0] = str_replace( $matches['metacafe.com'][0][0], $this->tag_metacafe( 'excerpt', $matches['metacafe.com'][0][4], 'v', $matches['metacafe.com'][0][5] ), $matches['metacafe.com'][0][0] );
876
- } else if ( $matches['metacafe.com'][0][2] == 'v' || $matches['metacafe.com'][0][2] == 'vh' || $matches['metacafe.com'][0][2] == 'vhd' ) {
877
- $matches['metacafe.com'][0][0] = str_replace( $matches['metacafe.com'][0][0], $this->tag_metacafe( 'excerpt', $matches['metacafe.com'][0][4], $matches['metacafe.com'][0][2], $matches['metacafe.com'][0][5] ), $matches['metacafe.com'][0][0] );
878
- }
879
- $result = $matches['metacafe.com'][0][0];
880
- } else if ( isset($matches['vimeo.com'][0] ) ) {
881
- if ( ( $matches['vimeo.com'][0][1] == 'http://' && $this->options['http'] == 'on' ) || ( $matches['vimeo.com'][0][1] == '' && $this->options['www'] == 'on' ) ) {
882
- $matches['vimeo.com'][0][0] = str_replace( $matches['vimeo.com'][0][0], $this->tag_vimeo( 'excerpt', $matches['vimeo.com'][0][4], 'v' ), $matches['vimeo.com'][0][0] );
883
- }
884
- else if ( $matches['vimeo.com'][0][2] == 'v' || $matches['vimeo.com'][0][2] == 'vh' || $matches['vimeo.com'][0][2] == 'vhd' ) {
885
- $matches['vimeo.com'][0][0] = str_replace( $matches['vimeo.com'][0][0], $this->tag_vimeo( 'excerpt', $matches['vimeo.com'][0][4], $matches['vimeo.com'][0][2] ), $matches['vimeo.com'][0][0] );
886
- }
887
- $result = $matches['vimeo.com'][0][0];
888
- } else if ( isset( $matches['liveleak.com'][0] ) ) {
889
- if ( ( $matches['liveleak.com'][0][1] == 'http://' && $this->options['http'] == 'on' ) || ( $matches['liveleak.com'][0][1] == '' && $this->options['www'] == 'on' ) ) {
890
- $matches['liveleak.com'][0][0] = str_replace( $matches['liveleak.com'][0][0], $this->tag_liveleak( 'excerpt', $matches['liveleak.com'][0][4], 'v' ), $matches['liveleak.com'][0][0] );
891
- } else if ( $matches['liveleak.com'][0][2] == 'v' || $matches['liveleak.com'][0][2] == 'vh' || $matches['liveleak.com'][0][2] == 'vhd' ) {
892
- $matches['liveleak.com'][0][0] = str_replace( $matches['liveleak.com'][0][0], $this->tag__liveleak( 'excerpt', $matches['liveleak.com'][0][4], $matches['liveleak.com'][0][2] ), $matches['liveleak.com'][0][0] );
893
- }
894
- $result = $matches['liveleak.com'][0][0];
895
- } else if ( isset( $matches['facebook.com'][0] ) ) {
896
- if ( ( $matches['facebook.com'][0][1] == 'http://' && $this->options['http'] == 'on' ) || ( $matches['facebook.com'][0][1] == '' && $this->options['www'] == 'on' ) ) {
897
- $matches['facebook.com'][0][0] = str_replace( $matches['facebook.com'][0][0], $this->tag_facebook( 'excerpt', $matches['facebook.com'][0][4], 'v' ), $matches['facebook.com'][0][0] );
898
- } else if ( $matches['facebook.com'][0][2] == 'v' || $matches['facebook.com'][0][2] == 'vh' || $matches['facebook.com'][0][2] == 'vhd' ) {
899
- $matches['facebook.com'][0][0] = str_replace( $matches['facebook.com'][0][0], $this->tag_facebook( 'excerpt', $matches['facebook.com'][0][4], $matches['facebook.com'][0][2] ), $matches['facebook.com'][0][0] );
900
- }
901
- $result = $matches['facebook.com'][0][0];
902
- } else {
903
- /*$width = $this->options['widthside'];
904
- $height = $this->options['heightside'];
905
-
906
- $img_url = htmlspecialchars( $this->plugin_url . '/img/default.jpg' );
907
- $post_url = get_permalink( $post->ID );
908
- $yte_tag = <<<EOT
909
- <a href="$post_url">
910
- <img src="$img_url" height="$height" width="$width" />
911
- </a>
912
- EOT;
913
- $result = str_replace( '{video}', $yte_tag, html_entity_decode( $template ) );*/
914
-
915
- return $the_content;
916
- }
917
- if ( isset( $result ) ) {
918
- $the_content = '<div style="float:' . $this->options["excerpt_align"] . ';padding-' . ( $this->options["excerpt_aign"] == 'left' ? 'right' : 'left' ) . ':10px;">' . $result . '</div>' . $the_content . '<div style="clear:both"></div>';
919
- }
920
- }
921
-
922
- if ( $this->first_post_on_archive ) {
923
- $this->first_post_on_archive = false;
924
- }
925
-
926
- return $the_content;
927
- }
928
-
929
- function tag_youtube( $context, $file, $high = 'v', $time = '' ) {
930
- $playlist = 0;
931
- $disp_rel = $this->options['rel'];
932
- $autoplay = $this->options['autoplay'];
933
- $autoplay_first = $this->options['autoplay_first'];
934
- $disp_search = $this->options['search'] == 'on' ? 1 : 0;
935
- $disp_info = $this->options['info'] == 'on' ? '&showinfo=0' : '';
936
- $disp_ann = $this->options['ann'] == 'on' ? '&iv_load_policy=3' : '';
937
- $template = trim( $this->options['template'] ) == '' ? '{video}' : $this->options['template'];
938
- $valid = $this->options['valid'];
939
- if ($this->options['loop'])
940
- $loop="&loop=1&playlist=$file";
941
- else $loop='';
942
- $thumb = $this->options['thumb'];
943
- $colorbox = $this->options['colorbox'];
944
- $logoless = $this->options['logoless'];
945
- $theme = $this->options['theme'];
946
- $excerpt = $this->options['excerpt'];
947
-
948
- switch ( $high ) {
949
- case 'v':
950
- $high = '';
951
- break;
952
- case 'vh':
953
- $high = '&amp;hd=1';
954
- break;
955
- case 'vhd':
956
- $high = '&amp;hd=1';
957
- break;
958
- case 'vp':
959
- $high = '';
960
- $playlist = 1;
961
- break;
962
- case 'vhp':
963
- $high = '&amp;hd=1';
964
- $playlist = 1;
965
- break;
966
- default:
967
- $high = '';
968
- break;
969
- }
970
-
971
- $width = ( $context == 'excerpt' || $context == 'side' ) ?
972
- $this->options['widthside'] :
973
- ( $high ? $this->options['widthhq'] : $this->options['width'] );
974
-
975
- $height = ( $context == 'excerpt' || $context == 'side' ) ?
976
- $this->options['heightside'] :
977
- ( $high ? $this->options['heighthq'] : $this->options['height'] );
978
-
979
- if ( ! $width ) {
980
- $width = ! $high ? 480 : 425 ;
981
- }
982
-
983
- if ( ! $height ) {
984
- $height = ! $high ? 360 : 344;
985
- }
986
-
987
- $ap = '';
988
- if ( is_single() ) {
989
- if ( $context == 'post' && $autoplay_first && ! $this->first ) {
990
- $ap = '&autoplay=1';
991
- $this->first = true;
992
- } else if ( ( $context == 'post' && $autoplay && ! $autoplay_first ) || ( $context == 'excerpt' && $autoplay ) ) {
993
- $ap = '&autoplay=1';
994
- } else {
995
- $ap = '';
996
- }
997
- } elseif ( $this->first_post_on_archive ) {
998
- if ( $context == 'post' && $autoplay_first && ! $this->first ) {
999
- $ap = '&autoplay=1';
1000
- $this->first = true;
1001
- } else if ( ( $context == 'post' && $autoplay && ! $autoplay_first ) || ( $context == 'excerpt' && $autoplay ) ) {
1002
- $ap = '&autoplay=1';
1003
- } else {
1004
- $ap = '';
1005
- }
1006
- }
1007
-
1008
- if ( $logoless == 'on' ) {
1009
- $ll = '&modestbranding=1';
1010
- $disp_info = '';
1011
- } else {
1012
- $ll = '';
1013
- }
1014
-
1015
- $root_url = $this->options['privacy'] ? 'http://www.youtube-nocookie.com' : 'http://www.youtube.com';
1016
-
1017
- if ( $excerpt == 'thm' ) {
1018
- $img_url = htmlspecialchars( "http://img.youtube.com/vi/$file/0.jpg" );
1019
- global $post;
1020
- $post_url = get_permalink( $post->ID );
1021
- $yte_tag = <<<EOT
1022
- <a href="$post_url"><img src="$img_url" height="$height" width="$width" /></a>
1023
- EOT;
1024
- }
1025
-
1026
- if ( ( ( is_home() || is_front_page() || is_archive() ) && $context == 'post' && $thumb == 'on' ) || ( $context == 'thumb' ) || ( $context == 'excerpt' && $excerpt == 'thm' ) ) {
1027
- $img_url = htmlspecialchars( "http://img.youtube.com/vi/$file/0.jpg" );
1028
- if ( $context == 'excerpt' && $excerpt == 'thm' ) {
1029
- global $post;
1030
- $post_url = get_permalink( $post->ID );
1031
- $yte_tag = <<<EOT
1032
- <a href="$post_url"><img src="$img_url" height="$height" width="$width" /></a>
1033
- EOT;
1034
- } else {
1035
- $yte_tag = <<<EOT
1036
- <img src="$img_url" height="$height" width="$width" />
1037
- EOT;
1038
- }
1039
- } else {
1040
- if ( $this->options['iframe'] == 'on' )
1041
- $video_url = htmlspecialchars( "$root_url/embed/$file?wmode=transparent&fs=1&hl=en$ap$ll$loop{$disp_info}$disp_ann&showsearch=$disp_search&rel=$disp_rel&theme=$theme", ENT_QUOTES ) . $high . $time;
1042
- else
1043
- $video_url = htmlspecialchars( "$root_url/v/$file?wmode=transparent&fs=1&hl=en&$ap$ll$loop{$disp_info}$disp_ann&showsearch=$disp_search&rel=$disp_rel&theme=$theme", ENT_QUOTES ) . $high . $time;
1044
-
1045
- if ( $playlist ) {
1046
- $video_url = htmlspecialchars( "$root_url/embed/videoseries?list=$file&fs=1&hl=en$ap$ll$loop{$disp_info}$disp_ann&showsearch=$disp_search&rel=$disp_rel&theme=$theme", ENT_QUOTES ) . $high . $time;
1047
- $yte_tag = <<<EOT
1048
- <span class="youtube"><iframe class="youtube-player" src="$video_url" width="$width" height="$height" frameborder="0" allowfullscreen></iframe></span>
1049
- EOT;
1050
- } elseif ( $valid == 'off' || strpos( $_SERVER['HTTP_USER_AGENT'], 'iPhone' ) === TRUE || strpos( $_SERVER['HTTP_USER_AGENT'], 'iPod' ) === TRUE || strpos( $_SERVER['HTTP_USER_AGENT'], 'iPad' ) === TRUE ) {
1051
- if ( $context == 'post' && $colorbox == 'on' && is_singular() ) {
1052
- $img_url = htmlspecialchars( "http://img.youtube.com/vi/$file/0.jpg" );
1053
- $yte_tag = <<<EOT
1054
- <a class="colorbox_video" href="$video_url"><img width="$width" height="$height" src="$img_url" /></iframe></span>
1055
- EOT;
1056
- } else if ( $this->options['iframe'] == 'on' )
1057
- $yte_tag = <<<EOT
1058
- <span class="youtube"><iframe title="YouTube video player" class="youtube-player" type="text/html" width="$width" height="$height" src="$video_url" frameborder="0" allowfullscreen></iframe></span>
1059
- EOT;
1060
- else
1061
- $yte_tag = <<<EOT
1062
- <span class="youtube"><object width="$width" height="$height"><param name="movie" value="$video_url" />
1063
- <param name="allowFullScreen" value="true" /><embed wmode="opaque" src="$video_url" type="application/x-shockwave-flash" allowfullscreen="true" width="$width" height="$height"></embed><param name="wmode" value="opaque" /></object></span>
1064
- EOT;
1065
- } else {
1066
- if ( $context == 'post' && $colorbox == 'on' && is_singular() ) {
1067
- $img_url = htmlspecialchars( "http://img.youtube.com/vi/$file/0.jpg" );
1068
- $yte_tag = <<<EOT
1069
- <a class="colorbox_video" href="$video_url"><img width="$width" height="$height" src="$img_url" /></iframe></span>
1070
- EOT;
1071
- } else if ( $this->options['iframe'] == 'on' ) {
1072
- $yte_tag = <<<EOT
1073
- <span class="youtube"><iframe title="YouTube video player" class="youtube-player" type="text/html" width="$width" height="$height" src="$video_url" frameborder="0" allowfullscreen></iframe></span>
1074
- EOT;
1075
- } else {
1076
- $yte_tag = <<<EOT
1077
- <span class="youtube"><object type="application/x-shockwave-flash" width="$width" height="$height" data="$video_url"><param name="movie" value="$video_url" />
1078
- <param name="allowFullScreen" value="true" /><param name="wmode" value="transparent" /></object></span>
1079
- EOT;
1080
- }
1081
- }
1082
- }
1083
-
1084
- if ( is_feed() && ( $context == 'post' || $context = 'excerpt' ) ) {
1085
- if ( $high ) {
1086
- $high = '&fmt=18';
1087
- }
1088
- if ( $playlist )
1089
- $url = 'http://www.youtube.com/playlist?list=';
1090
- else
1091
- $url = 'http://www.youtube.com/watch?v=';
1092
-
1093
- $yte_tag = '';
1094
- if ( $this->options['link'] == 'on' ) {
1095
- $yte_tag .= '<p><a href="' . $url . $file . $high . '">'.$url. $file . '</a></p>';
1096
- }
1097
-
1098
- if ( $this->options['img'] == 'on' ) {
1099
- $yte_tag .= '<p><a href="' . $url . $file . $high. '"><img src="http://img.youtube.com/vi/' . $file . '/default.jpg" width="130" height="97" border=0></a></p>';
1100
- }
1101
-
1102
- if ($this->options['link'] == 'off' && $this->options['img'] == 'off')
1103
- $yte_tag=$url.$file;
1104
- }
1105
-
1106
- return str_replace( '{video}', $yte_tag, html_entity_decode( $template ) );
1107
- }
1108
-
1109
- function tag_metacafe( $context, $file, $high = 'v', $name = '' ) {
1110
- $width = ( $context == 'excerpt' || $context == 'side' ) ?
1111
- $this->options['widthside'] :
1112
- ( $high ? $this->options['widthhq'] : $this->options['width'] );
1113
-
1114
- $height = ( $context == 'excerpt' || $context == 'side' ) ?
1115
- $this->options['heightside'] :
1116
- ( $high ? $this->options['heighthq'] : $this->options['height'] );
1117
-
1118
- if ( ! $width ) {
1119
- $width = ! ( $high == 'v' ) ? 480 : 425 ;
1120
- }
1121
-
1122
- if ( ! $height ) {
1123
- $height = ! ( $high == 'v' ) ? 360 : 344;
1124
- }
1125
-
1126
- $template = trim( $this->options['template'] ) == '' ? '{video}' : $this->options['template'];
1127
- $excerpt = $this->options['excerpt'];
1128
- $thumb = $this->options['thumb'];
1129
- $colorbox = $this->options['colorbox'];
1130
- $autoplay = $this->options['autoplay'];
1131
- $autoplay_first = $this->options['autoplay_first'];
1132
-
1133
- $ap = 'no';
1134
- if ( is_single() ) {
1135
- if ( $context == 'post' && $autoplay_first && ! $this->first ) {
1136
- $ap = 'yes';
1137
- $this->first = true;
1138
- } else if ( ( $context == 'post' && $autoplay && ! $autoplay_first ) || ( $context == 'excerpt' && $autoplay ) ) {
1139
- $ap = 'yes';
1140
- } else {
1141
- $ap = 'no';
1142
- }
1143
- } elseif ( $this->first_post_on_archive ) {
1144
- if ( $context == 'post' && $autoplay_first && ! $this->first ) {
1145
- $ap = 'yes';
1146
- $this->first = true;
1147
- } else if ( ( $context == 'post' && $autoplay && ! $autoplay_first ) || ( $context == 'excerpt' && $autoplay ) ) {
1148
- $ap = 'yes';
1149
- } else {
1150
- $ap = 'no';
1151
- }
1152
- }
1153
-
1154
- $flash_vars = "playerVars=showStats=no|autoPlay=$ap|";
1155
-
1156
- if ( ( ( is_home() || is_front_page() || is_archive() ) && $context == 'post' && $thumb == 'on' ) || ( $context == 'thumb' ) || ( $context == 'excerpt' && $excerpt == 'thm' ) ) {
1157
- $img_url = htmlspecialchars( "http://www.metacafe.com/thumb/$file.jpg" );
1158
- if ( $context == 'excerpt' && $excerpt == 'thm' ) {
1159
- global $post;
1160
- $post_url = get_permalink( $post->ID );
1161
- $yte_tag = <<<EOT
1162
- <a href="$post_url"><img src="$img_url" height="$height" width="$width" /></a>
1163
- EOT;
1164
- } else {
1165
- $yte_tag = <<<EOT
1166
- <img src="$img_url" height="$height" width="$width" />
1167
- EOT;
1168
- }
1169
- } else if ( $context == 'post' && $colorbox == 'on' && is_singular() ) {
1170
- $img_url = htmlspecialchars( "http://www.metacafe.com/thumb/$file.jpg" );
1171
- $yte_tag = <<<EOT
1172
- <a class="colorbox_video" href="http://www.metacafe.com/fplayer/$file/$name.swf"><img width="$width" height="$height" src="$img_url" /></iframe></span>
1173
- EOT;
1174
- } else {
1175
- $yte_tag = <<<EOT
1176
- <embed flashVars="$flash_vars" src="http://www.metacafe.com/fplayer/$file/$name.swf" width="$width" height="$height" wmode="transparent" allowFullScreen="true" allowScriptAccess="always" name="Metacafe_6261286" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>
1177
- EOT;
1178
- }
1179
-
1180
- return str_replace( '{video}', $yte_tag, html_entity_decode( $template ) );
1181
- }
1182
-
1183
- function tag_vimeo( $context, $file, $high = 'v', $side = 0 ) {
1184
- $width = ( $context == 'excerpt' || $context == 'side' ) ?
1185
- $this->options['widthside'] :
1186
- ( $high ? $this->options['widthhq'] : $this->options['width'] );
1187
-
1188
- $height = ( $context == 'excerpt' || $context == 'side' ) ?
1189
- $this->options['heightside'] :
1190
- ( $high ? $this->options['heighthq'] : $this->options['height'] );
1191
-
1192
- if ( ! $width ) {
1193
- $width = ! ( $high == 'v' ) ? 480 : 425 ;
1194
- }
1195
-
1196
- if ( ! $height ) {
1197
- $height = ! ( $high == 'v' ) ? 360 : 344;
1198
- }
1199
-
1200
- $template = trim( $this->options['template'] ) == '' ? '{video}' : $this->options['template'];
1201
- $excerpt = $this->options['excerpt'];
1202
- $thumb = $this->options['thumb'];
1203
- $colorbox = $this->options['colorbox'];
1204
- $autoplay = $this->options['autoplay'];
1205
- $autoplay_first = $this->options['autoplay_first'];
1206
- $loop = $this->options['loop'];
1207
-
1208
- $video_url = "http://player.vimeo.com/video/$file";
1209
-
1210
- if ( $context == 'post' && $autoplay_first && ! $this->first ) {
1211
- if ( is_single() ) {
1212
- $video_url .= "?autoplay=1";
1213
- } elseif ( $this->first_post_on_archive ) {
1214
- $video_url .= "?autoplay=1";
1215
- }
1216
- if ( $loop ) {
1217
- $video_url .= "&amp;loop=1";
1218
- }
1219
- $this->first = true;
1220
- } else if ( ( $context == 'post' && $autoplay && ! $autoplay_first ) || ( $context == 'excerpt' && $autoplay ) ) {
1221
- if ( is_single() ) {
1222
- $video_url .= "?autoplay=1";
1223
- } elseif ( $this->first_post_on_archive ) {
1224
- $video_url .= "?autoplay=1";
1225
- }
1226
- if ( $loop ) {
1227
- $video_url .= "&amp;loop=1";
1228
- }
1229
- } else {
1230
- if ( $loop ) {
1231
- $video_url .= "?loop=1";
1232
- }
1233
- }
1234
-
1235
- if ( ( ( is_home() || is_front_page() || is_archive() ) && $context == 'post' && $thumb == 'on' ) || ( $context == 'thumb' ) || ( $context == 'excerpt' && $excerpt == 'thm' ) ) {
1236
- $thumbs = unserialize(file_get_contents("http://vimeo.com/api/v2/video/$file.php"));
1237
- $img_url = htmlspecialchars($thumbs[0]['thumbnail_large']);
1238
- if ( $context == 'excerpt' && $excerpt == 'thm' ) {
1239
- global $post;
1240
- $post_url = get_permalink( $post->ID );
1241
- $yte_tag = <<<EOT
1242
- <a href="$post_url"><img src="$img_url" height="$height" width="$width" /></a>
1243
- EOT;
1244
- } else {
1245
- $yte_tag = <<<EOT
1246
- <img src="$img_url" height="$height" width="$width" />
1247
- EOT;
1248
- }
1249
- }
1250
- else if ( $context == 'post' && $colorbox == 'on' && is_singular() ) {
1251
- $thumbs = unserialize( file_get_contents( "http://vimeo.com/api/v2/video/$file.php" ) );
1252
- $img_url = htmlspecialchars( $thumbs[0]['thumbnail_large'] );
1253
- $yte_tag = <<<EOT
1254
- <a class="colorbox_video" href="$video_url"><img width="$width" height="$height" src="$img_url" /></a>
1255
- EOT;
1256
- } else {
1257
- $yte_tag = <<<EOT
1258
- <iframe src="$video_url" width="$width" height="$height" frameborder="0"></iframe>
1259
- EOT;
1260
- }
1261
-
1262
- return str_replace( '{video}', $yte_tag, html_entity_decode( $template ) );
1263
- }
1264
-
1265
- function tag_liveleak( $context, $file, $high = 'v', $side = 0 ) {
1266
- $width = ( $context == 'excerpt' || $context == 'side' ) ?
1267
- $this->options['widthside'] :
1268
- ( $high ? $this->options['widthhq'] : $this->options['width'] );
1269
-
1270
- $height = ( $context == 'excerpt' || $context == 'side' ) ?
1271
- $this->options['heightside'] :
1272
- ( $high ? $this->options['heighthq'] : $this->options['height'] );
1273
-
1274
- if ( ! $width ) {
1275
- $width = ! ( $high == 'v' ) ? 480 : 425 ;
1276
- }
1277
-
1278
- if ( ! $height ) {
1279
- $height = ! ( $high == 'v' ) ? 360 : 344;
1280
- }
1281
-
1282
- $template = trim($this->options['template']) == '' ? '{video}' : $this->options['template'];
1283
- $thumb = $this->options['thumb'];
1284
- $colorbox = $this->options['colorbox'];
1285
- $excerpt = $this->options['excerpt'];
1286
-
1287
- if ( ( ( is_home() || is_front_page() || is_archive() ) && $context == 'post' && $thumb == 'on' ) || ( $context == 'thumb' ) || ( $context == 'excerpt' && $excerpt == 'thm' ) ) {
1288
- $img_url = htmlspecialchars( $this->plugin_url . '/img/default.jpg' );
1289
- if ( $context == 'excerpt' && $excerpt == 'thm' ) {
1290
- global $post;
1291
- $post_url = get_permalink( $post->ID );
1292
- $yte_tag = <<<EOT
1293
- <a href="$post_url"><img src="$img_url" height="$height" width="$width" /></a>
1294
- EOT;
1295
- } else {
1296
- $yte_tag = <<<EOT
1297
- <img src="$img_url" height="$height" width="$width" />
1298
- EOT;
1299
- }
1300
- } else if ( $context == 'post' && $colorbox == 'on' && is_singular() ) {
1301
- $img_url = htmlspecialchars( $this->plugin_url . '/img/default.jpg' );
1302
- $yte_tag = <<<EOT
1303
- <a class="colorbox_video" href="http://www.liveleak.com/e/$file"><img width="$width" height="$height" src="$img_url" /></iframe></span>
1304
- EOT;
1305
- } else {
1306
- $yte_tag = <<<EOT
1307
- <object width="$width" height="$height"><param name="movie" value="http://www.liveleak.com/e/$file"></param><param name="wmode" value="transparent"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.liveleak.com/e/$file" type="application/x-shockwave-flash" wmode="transparent" allowscriptaccess="always" width="$width" height="$height"></embed></object>
1308
- EOT;
1309
- }
1310
-
1311
- return str_replace( '{video}', $yte_tag, html_entity_decode( $template ) );
1312
- }
1313
-
1314
- function tag_facebook( $context, $file, $high = 'v', $side = 0 ) {
1315
- $width = ( $context == 'excerpt' || $context == 'side' ) ?
1316
- $this->options['widthside'] :
1317
- ( $high ? $this->options['widthhq'] : $this->options['width'] );
1318
-
1319
- $height = ( $context == 'excerpt' || $context == 'side' ) ?
1320
- $this->options['heightside'] :
1321
- ( $high ? $this->options['heighthq'] : $this->options['height'] );
1322
-
1323
- if ( ! $width ) {
1324
- $width = ! ( $high == 'v' ) ? 480 : 425 ;
1325
- }
1326
-
1327
- if ( ! $height ) {
1328
- $height = ! ( $high == 'v' ) ? 360 : 344;
1329
- }
1330
-
1331
- $template = trim($this->options['template']) == '' ? '{video}' : $this->options['template'];
1332
- $thumb = $this->options['thumb'];
1333
- $colorbox = $this->options['colorbox'];
1334
- $excerpt = $this->options['excerpt'];
1335
-
1336
- if ( ( ( is_home() || is_front_page() || is_archive() ) && $context == 'post' && $thumb == 'on' ) || ( $context == 'thumb' ) || ( $context == 'excerpt' && $excerpt == 'thm' ) ) {
1337
- $img_url = htmlspecialchars( $this->plugin_url . '/img/default.jpg' );
1338
- if ( $context == 'excerpt' && $excerpt == 'thm' ) {
1339
- global $post;
1340
- $post_url = get_permalink( $post->ID );
1341
- $yte_tag = <<<EOT
1342
- <a href="$post_url"><img src="$img_url" height="$height" width="$width" /></a>
1343
- EOT;
1344
- } else {
1345
- $yte_tag = <<<EOT
1346
- <img src="$img_url" height="$height" width="$width" />
1347
- EOT;
1348
- }
1349
- } else if ( $context == 'post' && $colorbox == 'on' && is_singular() ) {
1350
- $img_url = htmlspecialchars( $this->plugin_url . '/img/default.jpg' );
1351
- $yte_tag = <<<EOT
1352
- <a class="colorbox_video" href="http://www.facebook.com/v/$file"><img width="$width" height="$height" src="$img_url" /></iframe></span>
1353
- EOT;
1354
- } else {
1355
- $yte_tag = <<<EOT
1356
- <object width="$width" height="$height"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" />
1357
- <param name="movie" value="http://www.facebook.com/v/$file" /><embed src="http://www.facebook.com/v/$file" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="$width" height="$height"></embed></object>
1358
- EOT;
1359
- }
1360
-
1361
- return str_replace( '{video}', $yte_tag, html_entity_decode( $template ) );
1362
- }
1363
-
1364
- function install() {
1365
- add_action( 'widgets_init', array( $this, 'load_widgets' ) );
1366
-
1367
- if ( get_option( $this->key ) ) {
1368
- $this->options = $this->get_options();
1369
- }
1370
- }
1371
-
1372
- // Handle our options
1373
- function get_options() {
1374
- $options = array(
1375
- 'posts' => 'on',
1376
- 'comments' => 'off',
1377
- 'img' => 'off',
1378
- 'width' => 425,
1379
- 'height' => 344,
1380
- 'widthhq' => 480,
1381
- 'heighthq' => 295,
1382
- 'widthside' => 200,
1383
- 'heightside' => 167,
1384
- 'rel' => 1,
1385
- 'link' => 'on',
1386
- 'valid' => 'off',
1387
- 'search' => 'off',
1388
- 'info' => 'on',
1389
- 'ann' => 'on',
1390
- 'template' => '{video}',
1391
- 'autoplay' => 0,
1392
- 'autoplay_first' => 0,
1393
- 'privacy' => 0,
1394
- 'wtext' => '',
1395
- 'wtitle' => '',
1396
- 'tag' => '',
1397
- 'iframe' => 'on',
1398
- 'http' => 'off',
1399
- 'www' => 'off',
1400
- 'loop' => 0,
1401
- 'thumb' => 'off',
1402
- 'colorbox' => 'off',
1403
- 'colorbox_theme' => 1,
1404
- 'excerpt' => 'not',
1405
- 'logoless' => 'on',
1406
- 'wiziapp' => 'off',
1407
- 'theme' => 'dark'
1408
- );
1409
- $saved = get_option( $this->key );
1410
-
1411
- if ( ! empty( $saved ) ) {
1412
- foreach ( $saved as $key => $option ) {
1413
- $options[$key] = $option;
1414
- }
1415
- }
1416
-
1417
- if ( $saved != $options ) {
1418
- update_option( $this->key, $options );
1419
- }
1420
-
1421
- return $options;
1422
- }
1423
-
1424
- function load_widgets() {
1425
- register_widget( 'SmartYouTube_Widget' );
1426
- }
1427
-
1428
- /**
1429
- * Gets plugin info from WordPress Codex repo
1430
- * @return mixed
1431
- */
1432
- function get_info() {
1433
- $checkfile = 'http://svn.wp-plugins.org/smart-youtube/trunk/smartyoutube.chk';
1434
-
1435
- $status = array();
1436
-
1437
- return $status; //???
1438
-
1439
- $vcheck = wp_remote_fopen( $checkfile );
1440
-
1441
- if ( $vcheck ) {
1442
- $version = $this->local_version;
1443
-
1444
- $status = explode( '@', $vcheck );
1445
- return $status;
1446
- }
1447
- }
1448
- }
1449
-
1450
- class SmartYouTube_Widget extends WP_Widget {
1451
- function SmartYouTube_Widget() {
1452
- $widget_ops = array( 'classname' => 'smart-youtube', 'description' => 'A widget which dispalys some video from Youtube.' );
1453
- $control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'smart-youtube' );
1454
- $this->WP_Widget( 'smart-youtube', 'Smart Youtube', $widget_ops, $control_ops );
1455
- }
1456
-
1457
- function widget( $args, $instance ) {
1458
- extract( $args );
1459
- $text = smart_youtube_check( $instance['text'], 1 );
1460
- $title = $instance['title'];
1461
-
1462
- echo
1463
- $before_widget,
1464
- $before_title, $title, $after_title,
1465
- $text,
1466
- $after_widget;
1467
- }
1468
-
1469
- function update( $new_instance, $old_instance ) {
1470
- $instance = $old_instance;
1471
-
1472
- $instance['text'] = strip_tags( $new_instance['text'] );
1473
- $instance['title'] = strip_tags( $new_instance['title'] );
1474
- return $instance;
1475
- }
1476
-
1477
- function form( $instance ) {
1478
- $defaults = array( 'title' => 'Smart Youtube Widget', 'text' => '' );
1479
- $instance = wp_parse_args( ( array )$instance, $defaults );
1480
- ?>
1481
- <?php _e('Title:', 'smart-youtube'); ?><br /><input type="text" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" /><br />
1482
- <?php _e('Insert HTML code below. In addition to normal text you may use httpv, httpvh and httpvhd links just like in your posts.'); ?><br />
1483
- <textarea id="<?php echo $this->get_field_id( 'text' ); ?>" name="<?php echo $this->get_field_name( 'text' ); ?>" rows="10" cols="16" class="widefat"><?php echo $instance['text']; ?></textarea>
1484
- <?php
1485
- }
1486
- }
1487
-
1488
- function smart_youtube_check( $the_content, $side = 0 ) {
1489
- global $smart_youtube_pro;
1490
- return $smart_youtube_pro->check( $the_content, $side );
1491
- }
1492
-
1493
- function syt_show_thumb( $post_id ) {
1494
- $p = get_post( $post_id );
1495
- $content = $p->post_content;
1496
-
1497
- preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?youtube\.com\/watch(\?v\=|\/v\/|#!v=)([a-zA-Z0-9\-\_]{11})([^<\s]*)/", $content, $matches['youtube.com'], PREG_SET_ORDER );
1498
- preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?youtu\.be\/([a-zA-Z0-9\-\_]{11})/", $content, $matches['youtu.be'], PREG_SET_ORDER );
1499
- preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?metacafe\.com\/watch\/([a-zA-Z0-9\-\_]{7})\/([^<^\/\s]*)([\/])?/", $content, $matches['metacafe.com'], PREG_SET_ORDER );
1500
- preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?vimeo\.com\/([a-zA-Z0-9\-\_]{8})([\/])?/", $content, $matches['vimeo.com'], PREG_SET_ORDER );
1501
- preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?liveleak\.com\/view(\?i\=)([a-zA-Z0-9\-\_]*)/", $content, $matches['liveleak.com'], PREG_SET_ORDER );
1502
- preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?facebook\.com\/video\/video.php\?v\=([a-zA-Z0-9\-\_]*)/", $content, $matches['facebook.com'], PREG_SET_ORDER );
1503
-
1504
- global $smart_youtube_pro;
1505
-
1506
- if ( isset( $matches['youtube.com'][0] ) ) {
1507
- if ( ( $matches['youtube.com'][0][1] == 'http://' && $smart_youtube_pro->options['http'] == 'on' ) || ( $matches['youtube.com'][0][1] == '' && $smart_youtube_pro->options['www'] == 'on' ) ) {
1508
- $matches['youtube.com'][0][0] = str_replace( $matches['youtube.com'][0][0], $smart_youtube_pro->tag_youtube( 'excerpt', $matches['youtube.com'][0][5], 'v', $matches['youtube.com'][0][6] ), $matches['youtube.com'][0][0] );
1509
- } else if ( $matches['youtube.com'][0][2] == 'v' || $matches['youtube.com'][0][2] == 'vh' || $matches['youtube.com'][0][2] == 'vhd' ) {
1510
- $matches['youtube.com'][0][0] = str_replace( $matches['youtube.com'][0][0], $smart_youtube_pro->tag_youtube( 'excerpt', $matches['youtube.com'][0][5], $matches['youtube.com'][0][2], $matches['youtube.com'][0][6] ), $matches['youtube.com'][0][0] );
1511
- }
1512
- $result = $matches['youtube.com'][0][0];
1513
- } else if ( isset( $matches['youtu.be'][0] ) ) {
1514
- if ( ( $matches['youtu.be'][0][1] == 'http://' && $smart_youtube_pro->options['http'] == 'on' ) || ( $matches['youtu.be'][0][1] == '' && $smart_youtube_pro->options['www'] == 'on' ) ) {
1515
- $matches['youtu.be'][0][0] = str_replace( $matches['youtu.be'][0][0], $smart_youtube_pro->tag_youtube( 'excerpt', $matches['youtu.be'][0][4], 'v' ), $matches['youtu.be'][0][0] );
1516
- } else if ( $matches['youtu.be'][0][2] == 'v' || $matches['youtu.be'][0][2] == 'vh' || $matches['youtu.be'][0][2] == 'vhd' ) {
1517
- $matches['youtu.be'][0][0] = str_replace( $matches['youtu.be'][0][0], $smart_youtube_pro->tag_youtube( 'excerpt', $matches['youtu.be'][0][4], $matches['youtu.be'][0][2]), $matches['youtu.be'][0][0] );
1518
- }
1519
- $result = $matches['youtu.be'][0][0];
1520
- } else if ( isset( $matches['metacafe.com'][0] ) ) {
1521
- if ( ( $matches['metacafe.com'][0][1] == 'http://' && $smart_youtube_pro->options['http'] == 'on' ) || ( $matches['metacafe.com'][0][1] == '' && $smart_youtube_pro->options['www'] == 'on' ) ) {
1522
- $matches['metacafe.com'][0][0] = str_replace( $matches['metacafe.com'][0][0], $smart_youtube_pro->tag_metacafe( 'excerpt', $matches['metacafe.com'][0][4], 'v', $matches['metacafe.com'][0][5] ), $matches['metacafe.com'][0][0] );
1523
- } else if ( $matches['metacafe.com'][0][2] == 'v' || $matches['metacafe.com'][0][2] == 'vh' || $matches['metacafe.com'][0][2] == 'vhd' ) {
1524
- $matches['metacafe.com'][0][0] = str_replace( $matches['metacafe.com'][0][0], $smart_youtube_pro->tag_metacafe( 'excerpt', $matches['metacafe.com'][0][4], $matches['metacafe.com'][0][2], $matches['metacafe.com'][0][5] ), $matches['metacafe.com'][0][0] );
1525
- }
1526
- $result = $matches['metacafe.com'][0][0];
1527
- } else if ( isset($matches['vimeo.com'][0] ) ) {
1528
- if ( ( $matches['vimeo.com'][0][1] == 'http://' && $smart_youtube_pro->options['http'] == 'on' ) || ( $matches['vimeo.com'][0][1] == '' && $smart_youtube_pro->options['www'] == 'on' ) ) {
1529
- $matches['vimeo.com'][0][0] = str_replace( $matches['vimeo.com'][0][0], $smart_youtube_pro->tag_vimeo( 'excerpt', $matches['vimeo.com'][0][4], 'v' ), $matches['vimeo.com'][0][0] );
1530
- }
1531
- else if ( $matches['vimeo.com'][0][2] == 'v' || $matches['vimeo.com'][0][2] == 'vh' || $matches['vimeo.com'][0][2] == 'vhd' ) {
1532
- $matches['vimeo.com'][0][0] = str_replace( $matches['vimeo.com'][0][0], $smart_youtube_pro->tag_vimeo( 'excerpt', $matches['vimeo.com'][0][4], $matches['vimeo.com'][0][2] ), $matches['vimeo.com'][0][0] );
1533
- }
1534
- $result = $matches['vimeo.com'][0][0];
1535
- } else if ( isset( $matches['liveleak.com'][0] ) ) {
1536
- if ( ( $matches['liveleak.com'][0][1] == 'http://' && $smart_youtube_pro->options['http'] == 'on' ) || ( $matches['liveleak.com'][0][1] == '' && $smart_youtube_pro->options['www'] == 'on' ) ) {
1537
- $matches['liveleak.com'][0][0] = str_replace( $matches['liveleak.com'][0][0], $smart_youtube_pro->tag_liveleak( 'excerpt', $matches['liveleak.com'][0][4], 'v' ), $matches['liveleak.com'][0][0] );
1538
- } else if ( $matches['liveleak.com'][0][2] == 'v' || $matches['liveleak.com'][0][2] == 'vh' || $matches['liveleak.com'][0][2] == 'vhd' ) {
1539
- $matches['liveleak.com'][0][0] = str_replace( $matches['liveleak.com'][0][0], $smart_youtube_pro->tag__liveleak( 'excerpt', $matches['liveleak.com'][0][4], $matches['liveleak.com'][0][2] ), $matches['liveleak.com'][0][0] );
1540
- }
1541
- $result = $matches['liveleak.com'][0][0];
1542
- } else if ( isset( $matches['facebook.com'][0] ) ) {
1543
- if ( ( $matches['facebook.com'][0][1] == 'http://' && $smart_youtube_pro->options['http'] == 'on' ) || ( $matches['facebook.com'][0][1] == '' && $smart_youtube_pro->options['www'] == 'on' ) ) {
1544
- $matches['facebook.com'][0][0] = str_replace( $matches['facebook.com'][0][0], $smart_youtube_pro->tag_facebook( 'excerpt', $matches['facebook.com'][0][4], 'v' ), $matches['facebook.com'][0][0] );
1545
- } else if ( $matches['facebook.com'][0][2] == 'v' || $matches['facebook.com'][0][2] == 'vh' || $matches['facebook.com'][0][2] == 'vhd' ) {
1546
- $matches['facebook.com'][0][0] = str_replace( $matches['facebook.com'][0][0], $smart_youtube_pro->tag_facebook( 'excerpt', $matches['facebook.com'][0][4], $matches['facebook.com'][0][2] ), $matches['facebook.com'][0][0] );
1547
- }
1548
- $result = $matches['facebook.com'][0][0];
1549
- } else {
1550
- $width = $smart_youtube_pro->options['width'];
1551
- $height = $smart_youtube_pro->options['height'];
1552
-
1553
- $img_url = htmlspecialchars( $smart_youtube_pro->plugin_url . '/img/default.jpg' );
1554
- $post_url = get_permalink( $post->ID );
1555
- $yte_tag = <<<EOT
1556
- <a href="$post_url">
1557
- <img src="$img_url" height="$height" width="$width" />
1558
- </a>
1559
- EOT;
1560
- $result = str_replace( '{video}', $yte_tag, html_entity_decode( $template ) );
1561
- }
1562
- if ( isset( $result ) ) {
1563
- return $result;
1564
- }
1565
- }
1566
- ?>
1
+ <?php
2
+ /*
3
+ Plugin Name: Smart Youtube PRO
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: 4.1.9
8
+ Author URI: http://www.prelovac.com/vladimir/
9
+
10
+
11
+ To-Do:
12
+
13
+ - Is there a way to have smart youtube display multiple thumbnails of youtube videos in this fashion:
14
+ http://wordpress.org/extend/plugins/my-youtube-playlist/
15
+
16
+ The author of this plugin has done a good job in birthing the concept, but is unable to really do much by way of support or add features, e.g. highlight thumbnail currently playing, flexible grouping styles of thumbnails (horizontal, vertical listing) etc.
17
+
18
+ - Wondering if there's a way to have smartyoutube generate a thumbnail of the youtube video that shows up as one of the thumbnail options for the article when someone shares the blog post?
19
+
20
+ - Would it be possible to overwrite the global autoplay param in a post, something like httpv://www.youtube.com/watch?v=00000000&autoplay=true; I tried to add autoplay=1 but unfortunately in the resuling html it adds autoplay=0 (the global option) and also autoplay=1
21
+ The result is no autoplay :(
22
+
23
+ - Instead of editing the shortcut, we have copied from youtube.
24
+ I would love to have a button,
25
+ like insert Smart YouTube Video
26
+ A dialogue box would pop up,
27
+ and allow me to just simply paste the link.
28
+ Then having check boxes on the side,
29
+ which allow me to choose whether you would like HD or not.
30
+ thus editing the link correctly.
31
+
32
+ I find this would greatly help, especiall when I help create video blogs for community provider who have very little computer background.
33
+
34
+ - Please add support for it on the BuddyPress Acitivity page, currently it just shows the url (which won't work because of the httpv and httpvh)
35
+
36
+ - Was wondering if it was possible for you to have the plugin take the URL for the Youtube thumbnail for the video and place it into a user defined custom field. The plugin "YoutubeThumb2CustomField" but no longer works in WP 3.0 (network).
37
+
38
+ - love to see vimeo support! i have video intensive site...love Vimeo
39
+
40
+ Only issue is I would LOVE to add the widget into another sidebar and I do not see this possibility. Can you have multiple Smart YouTubes?
41
+
42
+ - 1. Adding few possibilities for posting videos into post � I have great production of videos but before end of 2009 all was in 320 x 240 and after end of 2009 I start publishing video in 640 x 480 resolution. I have adjusted player video for 640 x 480 but now 320 x 240 videos are stretched across all of player window.
43
+
44
+ For changes to be easy implemented � I suggest adding 2 or even 3 possibilities for playing videos � like this:
45
+ Your original code httpv://www.youtube.com/********************
46
+ Another version of httpv#1://www.youtube.com/********************
47
+ Another version of httpv#2://www.youtube.com/********************
48
+ Another version of httpv#3://www.youtube.com/********************
49
+
50
+ Adding #1 after v will allow us to predefine what will be size of player for #1 or number #2 or number #3 � I think it is good idea
51
+
52
+ If you don�t put #1, #2, #3 player will be those which is default (without number) � in my case that is 640 x 480.
53
+
54
+ 2. If some video is for �personal use� which mean somebody must be log into you tube to see it, than I suggest making possibility for login for authors of those videos � If I put all my materials to be private (up to 25 people can see it) � than I cant publish them trough this way � and allowing authors to write theirs username and password will allow that those vides can be seen on my posts. That way I can protect all my archive of video on youtube, but allow those video can be visible on my blog � which can increase hits, visits and others possibility � that possibility is visible on this plug in http://tubepress.org/ where people can use its username and password for publishing all vides from if they have account on youtube
55
+
56
+
57
+ - marinas javascript suggestion for hq videos
58
+ - add editor button
59
+ - 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.
60
+ - localization
61
+ - the images appear under the embedded Smart Youtube videos. Is there any way to edit the z-index for Smart Youtube CSS? I
62
+ - would like to use multiple instances of the Smart YouTube plugin. I saw the reply that said to simply use multiple calls in one instance of the widget, but that doesn't let me choose different videos for different pages.
63
+ - was wondering if it's possible to get a vid and playlist in a custom page template?? Is it possible to add a preview image to search results?
64
+ - I wondered if there were a way to bring the video to the forefront layer (perhaps z-index)? I know this actually breaks good design practice in my intended use, but have a look here:
65
+ - However, on one page I have two videos and therefore I want to add a a parameter to the second video embed URL to _not_ start automatically. Something like httpv://www.youtube.com/watch?v=xyz123&autostart=off
66
+ - Single videos work well from wordpress on the Iphone/ipod. Is there a way to make the playlists work, just getting the ? cube instead of image.
67
+ - I would like to "inject" automatically this preview image url in a custom field, in each post, to auto-generate the thumb on my homepage with this image.
68
+ */
69
+
70
+
71
+
72
+ if (isset($smart_youtube_pro)) return false;
73
+
74
+ $smart_youtube_pro = new SmartYouTube_PRO();
75
+
76
+ class SmartYouTube_PRO {
77
+ var $local_version;
78
+ var $plugin_url;
79
+ var $options;
80
+ var $key;
81
+ var $first;
82
+ var $first_post_on_archive;
83
+
84
+ function SmartYouTube() {
85
+ $this->__construct();
86
+ }
87
+
88
+ function __construct() {
89
+ $this->local_version = '1.0'; // TODO: Change this number???
90
+
91
+ $this->plugin_url = trailingslashit(plugins_url(null,__FILE__));
92
+
93
+
94
+ $this->key = 'smart_youtube_pro';
95
+ $this->first_post_on_archive = false;
96
+
97
+ $script_path = $this->plugin_url . '/javascripts/jquery.colorbox-min.js';
98
+ wp_register_script( 'colorbox', $script_path );
99
+
100
+ $this->options = $this->get_options();
101
+
102
+ $this->add_filters_and_hooks();
103
+ }
104
+
105
+ function add_filters_and_hooks() {
106
+ if ( $this->options['posts'] == 'on' ) {
107
+ add_filter( 'the_content', array( $this, 'check' ), 5 );
108
+ add_filter( 'the_excerpt', array( $this, 'check_excerpt' ), 5 );
109
+ }
110
+
111
+ if ( $this->options['comments'] == 'on' ) {
112
+ add_filter( 'comment_text', array( $this, 'check' ), 100 );
113
+ }
114
+
115
+ add_action( 'plugins_loaded', array( $this, 'install' ) );
116
+ add_action( 'admin_menu', array( $this, 'add_menu_items' ) );
117
+ add_action( 'admin_head', array( $this, 'plugin_header' ) );
118
+ add_action( 'wp_head', array( $this, 'post_header' ) );
119
+ add_action( 'wp_print_scripts', array( $this, 'load_scripts' ) );
120
+ add_action( 'wp_print_styles', array( $this, 'load_styles' ) );
121
+ add_action( 'template_redirect', array( $this, 'mark_first_post_on_archive' ) );
122
+
123
+ register_activation_hook(__FILE__, array($this, 'install' ) );
124
+ }
125
+
126
+ function post_header() {
127
+ global $wp_query;
128
+ $the_content = $wp_query->post->post_content;
129
+ $char_codes = array( '&#215;', '&#8211;' );
130
+ $replacements = array( "x", "--" );
131
+ $the_content = str_replace( $char_codes, $replacements, $the_content );
132
+
133
+ 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 );
134
+
135
+ if ( isset( $matches[0][5] ) )
136
+ if ( $matches[0][5] != '' )
137
+ echo '<meta property="og:image" content="http://i.ytimg.com/vi/' . $matches[0][5] . '/default.jpg" />';
138
+
139
+ if ( $this->options['colorbox'] == 'on' ) {
140
+ ?>
141
+ <script>
142
+ jQuery(document).ready(function($){
143
+ $(".colorbox_video").colorbox({iframe:true, innerWidth:<?php echo $this->options['width']; ?>, innerHeight:<?php echo $this->options['height']; ?>});
144
+ });
145
+ </script>
146
+ <?php
147
+ }
148
+ }
149
+
150
+ function load_scripts() {
151
+ if ( $this->options["colorbox"] == 'on' ) {
152
+ wp_enqueue_script( 'jquery' );
153
+ wp_enqueue_script( 'colorbox' );
154
+ }
155
+ }
156
+
157
+ function load_styles() {
158
+ $style_path = $this->plugin_url . '/themes/theme' . $this->options['colorbox_theme'] . '/colorbox.css';
159
+ wp_register_style( 'colorbox', $style_path );
160
+
161
+ if ( $this->options["colorbox"] == 'on' ) {
162
+ wp_enqueue_style( 'colorbox' );
163
+ }
164
+ }
165
+
166
+ function plugin_header() {
167
+ if ( ! empty( $_REQUEST['page'] ) )
168
+ $page = $_REQUEST['page'];
169
+ else
170
+ $page = '';
171
+ ?>
172
+ <style>
173
+ <?php if ( ( $page == 'syt_settings' ) || ( $page == 'syt_colorbox_options' ) || ( $page == 'syt_about' ) ) : ?>
174
+ #icon-syt_settings { background:transparent url('<?php echo $this->plugin_url .'i/logo.png';?>') no-repeat; }
175
+ <?php endif; ?>
176
+ </style>
177
+ <script>
178
+ <?php if ( $page == 'syt_settings' ) : ?>
179
+ jQuery(document).ready(function($){
180
+ if (($)('#disp_excerpt').val() == 'not')
181
+ ($)('#disp_excerpt_align_div').hide();
182
+ else
183
+ ($)('#disp_excerpt_align_div').show();
184
+ ($)('#disp_excerpt').change(function(){
185
+ if (($)(this).val() == 'not')
186
+ ($)('#disp_excerpt_align_div').hide();
187
+ else
188
+ ($)('#disp_excerpt_align_div').show();
189
+ });
190
+ });
191
+ <?php endif; ?>
192
+ <?php if ( $page == 'syt_colorbox_options' ) : ?>
193
+ jQuery(document).ready(function($){
194
+ $("#colorbox_theme").change(function() {
195
+ var src = $("option:selected", this).val();
196
+ if ( src != "" ){
197
+ var $imgTag = "<img src=\"" + "<?php echo $this->plugin_url; echo '/screenshots/screenshot-'; ?>" + src + ".jpg\" />";
198
+ $("#screenshot_image").empty().html($imgTag).fadeIn();
199
+ }
200
+ });
201
+ });
202
+ <?php endif; ?>
203
+ </script>
204
+ <?php
205
+ }
206
+
207
+ function add_menu_items() {
208
+ $image = $this->plugin_url . '/i/icon.png';
209
+ add_menu_page( __( 'Smart Youtube', 'smart-youtube' ), __( 'Smart Youtube', 'smart-youtube' ), 'manage_options', 'syt_settings', array(
210
+ &$this,
211
+ 'options_page'
212
+ ), $image);
213
+ $page_settings = add_submenu_page( 'syt_settings', __( 'Smart Youtube', 'smart-youtube' ) . __( ' Settings', 'smart-youtube' ), __( 'Settings', 'smart-youtube' ), 'manage_options', 'syt_settings', array(
214
+ &$this,
215
+ 'options_page'
216
+ ) );
217
+ $page_colorbox = add_submenu_page( 'syt_settings', __( 'Smart Youtube', 'smart-youtube' ) . __( ' Colorbox Options', 'smart-youtube' ), __( 'Colorbox Options', 'smart-youtube' ), 'manage_options', 'syt_colorbox_options', array(
218
+ &$this,
219
+ 'handle_colorbox_options'
220
+ ) );
221
+ $page_about = add_submenu_page( 'syt_settings', __( 'Smart Youtube', 'smart-youtube' ) . __( ' About', 'smart-youtube' ), __( 'About', 'smart-youtube' ), 'manage_options', 'syt_about', array(
222
+ &$this,
223
+ 'handle_about'
224
+ ) );
225
+ }
226
+
227
+ function options_page() {
228
+ // If form was submitted
229
+ if ( isset( $_POST['submitted'] ) ) {
230
+ check_admin_referer( 'smart-youtube' );
231
+
232
+ $this->options['img'] = ! isset( $_POST['disp_img'] ) ? 'off' : 'on';
233
+ $this->options['link'] = ! isset( $_POST['disp_link'] ) ? 'off' : 'on';
234
+ $this->options['valid'] = ! isset( $_POST['valid'] ) ? 'off' : 'on';
235
+ $this->options['search'] = ! isset( $_POST['disp_search'] ) ? 'off' : 'on';
236
+ $this->options['ann'] = ! isset( $_POST['disp_ann'] ) ? 'off' : 'on';
237
+
238
+ $this->options['info'] = ! isset( $_POST['disp_info'] ) ? 'off' : 'on';
239
+
240
+ $this->options['width'] = ! isset( $_POST['disp_width'] ) ? 425 : intval( $_POST['disp_width'] );
241
+ $this->options['height'] = ! isset( $_POST['disp_height'] ) ? 344 : intval( $_POST['disp_height'] );
242
+
243
+ $this->options['widthhq'] = ! isset( $_POST['disp_widthhq'] ) ? 480 : intval( $_POST['disp_widthhq'] );
244
+ $this->options['heighthq'] = ! isset( $_POST['disp_heighthq'] ) ? 295 : intval( $_POST['disp_heighthq'] );
245
+
246
+ $this->options['widthside'] = ! isset( $_POST['disp_widthside'] ) ? 150 : intval( $_POST['disp_widthside'] );
247
+ $this->options['heightside'] = ! isset( $_POST['disp_heightside'] ) ? 125 : intval( $_POST['disp_heightside'] );
248
+
249
+ $this->options['rel'] = ! isset( $_POST['embedRel'] ) ? 1 : $_POST['embedRel'];
250
+ $this->options['autoplay'] = ! isset( $_POST['autoplay'] ) ? 0 : 1;
251
+ $this->options['autoplay_first'] = ! isset( $_POST['autoplay_first'] ) ? 0 : 1;
252
+ $this->options['privacy'] = ! isset( $_POST['disp_privacy'] ) ? 0 : 1;
253
+
254
+ $this->options['posts'] = ! isset( $_POST['disp_posts'] ) ? 'off' : 'on';
255
+ $this->options['comments'] = ! isset( $_POST['disp_comments'] ) ? 'off' : 'on';
256
+ $this->options['iframe'] = ! isset( $_POST['iframe'] ) ? 'off' : 'on';
257
+ $this->options['www'] = ! isset( $_POST['www'] ) ? 'off' : 'on';
258
+ $this->options['http'] = ! isset( $_POST['http'] ) ? 'off' : 'on';
259
+
260
+ $this->options['template'] = ! isset( $_POST['disp_template'] ) ? '{video}' : stripslashes( htmlspecialchars( $_POST['disp_template'] ) );
261
+ $this->options['tag'] = ! isset( $_POST['tag'] ) ? '' : $_POST['tag'];
262
+ $this->options['wiziapp'] = ! isset( $_POST['wiziapp'] ) ? 'off' : 'on';
263
+ $this->options['loop'] = ! isset( $_POST['loop'] ) ? 0 : 1;
264
+ $this->options['thumb'] = ! isset( $_POST['thumb'] ) ? 'off' : 'on';
265
+ $this->options['colorbox'] = ! isset( $_POST['colorbox'] ) ? 'off' : 'on';
266
+ $this->options['excerpt'] = ! isset( $_POST['excerpt'] ) ? '' : $_POST['excerpt'];
267
+ $this->options['excerpt_align'] = ! isset( $_POST['excerpt_align'] ) ? '' : $_POST['excerpt_align'];
268
+ $this->options['logoless'] = ! isset( $_POST['logoless'] ) ? 'off' : 'on';
269
+ $this->options['theme'] = ! isset( $_POST['theme'] ) ? '' : $_POST['theme'];
270
+
271
+ update_option( $this->key, $this->options );
272
+
273
+ // Show message
274
+ echo '<div id="message" class="updated fade"><p>' . __( 'Smart Youtube options saved.', 'smart-youtube' ) . '</p></div>';
275
+ }
276
+
277
+ $disp_img = $this->options['img'] == 'on' ? 'checked="checked"' : '';
278
+ $disp_link = $this->options['link'] == 'on' ? 'checked="checked"' : '';
279
+ $disp_search = $this->options['search'] == 'on' ? 'checked="checked"' : '';
280
+ $disp_ann = $this->options['ann'] == 'on' ? 'checked="checked"' : '';
281
+ $disp_info = $this->options['info'] == 'on' ? 'checked="checked"' : '';
282
+
283
+ $valid = $this->options['valid'] == 'on' ? 'checked="checked"' : '';
284
+
285
+ $disp_width = $this->options['width'];
286
+ $disp_height = $this->options['height'];
287
+
288
+ $disp_widthhq = $this->options['widthhq'];
289
+ $disp_heighthq = $this->options['heighthq'];
290
+
291
+ $disp_widthside = $this->options['widthside'];
292
+ $disp_heightside = $this->options['heightside'];
293
+
294
+ $disp_autoplay = $this->options['autoplay'] ? 'checked="checked"' : '';
295
+ $disp_autoplay_first = $this->options['autoplay_first'] ? 'checked="checked"' : '';
296
+ $disp_rel = $this->options['rel'] ? 'checked="checked"' : '';
297
+ $disp_rel2 = $this->options['rel'] ? '' : 'checked="checked"';
298
+ $disp_posts = $this->options['posts'] == 'on' ? 'checked="checked"' : '' ;
299
+ $disp_comments = $this->options['comments'] == 'on' ? 'checked="checked"' : '';
300
+
301
+ $disp_privacy = $this->options['privacy'] ? 'checked="checked"' : '';
302
+ $iframe = $this->options['iframe'] =='on' ? 'checked="checked"' : '';
303
+ $www = $this->options['www'] =='on' ? 'checked="checked"' : '';
304
+ $http = $this->options['http'] =='on' ? 'checked="checked"' : '';
305
+ $disp_loop = $this->options['loop'] ? 'checked="checked"' : '';
306
+ $thumb = $this->options['thumb'] == 'on' ? 'checked="checked"' : '';
307
+ $colorbox = $this->options['colorbox'] == 'on' ? 'checked="checked"' : '';
308
+ $excerpt = isset( $this->options['excerpt'] ) ? $this->options['excerpt'] : 'not';
309
+ $excerpt_align = isset( $this->options['excerpt_align'] ) ? $this->options['excerpt_align'] : 'left';
310
+
311
+ $disp_template = esc_html( $this->options['template'] );
312
+ $tag = $this->options['tag'];
313
+ $wiziapp = $this->options['wiziapp'] == 'on' ? 'checked="checked"' : '';
314
+ $logoless = $this->options['logoless'] == 'on' ? 'checked="checked"' : '';
315
+ $theme = isset( $this->options['theme'] ) ? $this->options['theme'] : '';
316
+
317
+ if ( ! $disp_width ) {
318
+ $disp_width = 425;
319
+ }
320
+
321
+ if ( ! $disp_height ) {
322
+ $disp_height = 344;
323
+ }
324
+
325
+ global $wp_version;
326
+
327
+ $embed_img = $this->plugin_url . '/img/embed_selection-vfl29294.png';
328
+
329
+ echo '<script src="' . $this->plugin_url . '/yt.js" type="text/javascript"></script>
330
+ <link rel="stylesheet" type="text/css" href="' . $this->plugin_url . '/styleyt.css" />';
331
+
332
+ $imgpath = $this->plugin_url.'/i';
333
+ $actionurl = stripslashes(htmlentities(strip_tags($_SERVER['REQUEST_URI'])));
334
+ $nonce = wp_create_nonce( 'smart-youtube' );
335
+ $example = htmlentities( '<div style="float:left;margin-right: 10px;">{video}</div>' );
336
+
337
+ // Configuration Page
338
+
339
+ ?>
340
+ <div class="wrap smartyoutube" >
341
+ <?php screen_icon(); ?>
342
+ <h2><?php _e( 'Smart YouTube PRO', 'smart-youtube' ); ?></h2>
343
+ <a href="admin.php?page=syt_settings"><?php _e( 'Settings', 'smart-youtube' ); ?></a> &nbsp;|&nbsp; <a href="admin.php?page=syt_colorbox_options"><?php _e( 'Colorbox Options', 'smart-youtube' ); ?></a> &nbsp;|&nbsp; <a href="admin.php?page=syt_about"><?php _e( 'About', 'smart-youtube' ); ?></a>
344
+ <div id="poststuff" style="margin-top:10px;">
345
+ <div id="sideblock" style="float:right;width:270px;margin-left:10px;">
346
+ <iframe width=270 height=800 frameborder="0" src="http://www.prelovac.com/plugin/news.php?id=0&utm_source=plugin&utm_medium=plugin&utm_campaign=Smart%2BYoutube"></iframe>
347
+ </div>
348
+ <div id="mainblock" style="width:710px">
349
+ <div class="dbx-content">
350
+ <h2 id="usageHeader"><?php _e( 'Usage <span style="font-size:small">[<a href="#">view instructions</a>]</span>', 'smart-youtube' ); ?></h2>
351
+ <div id="usage" style="display:none">
352
+ <p><?php _e( 'To use the video in your posts, paste YouTube video URL with <strong>httpv://</strong> (notice the \'v\').', 'smart-youtube' ); ?> </p>
353
+ <p><?php _e( '<strong>Important:</strong> The URL should just be copied into your post normally and the letter \'v\' added, do not create a clickable link!', 'smart-youtube' ); ?></p>
354
+ <p><?php _e( 'Example: httpv://www.youtube.com/watch?v=OWfksMD4PAg', 'smart-youtube' ); ?></p>
355
+ <p><?php _e( 'If you want to embed High/HD Quality video use <strong>httpvh://</strong> instead (Video High Defintion).', 'smart-youtube' ); ?></p>
356
+ <p><?php _e( 'Vimeo Example: httpv://vimeo.com/27287078', 'smart-youtube' ); ?></p>
357
+ <p><?php _e( 'Metacafe Example: httpvh://vww.metacafe.com/watch/7815470/harry_potter_and_the_deathly_hallows_dvd_interview/', 'smart-youtube' ); ?></p>
358
+ <p><?php _e( 'Live Leak Example: httpv://www.liveleak.com/view?i=cad_1322822486', 'smart-youtube' ); ?></p>
359
+ <p><?php _e( 'To embed playlists use httpvp:// (eg. httpvp://www.youtube.com/playlist?list=PL050E43A49BC5E5E5)', 'smart-youtube' ); ?></p>
360
+ <p><?php _e( 'Smart Youtube also supports migrated blogs from Wordpress.com using [youtube=youtubeadresss]', 'smart-youtube' ); ?></p>
361
+ <ul>
362
+ <li><?php _e( 'httpv:// - regular video', 'smart-youtube' ); ?></li>
363
+ <li><?php _e( 'httpvh:// - high/HD quality', 'smart-youtube' ); ?></li>
364
+ <li><?php _e( 'httpvp:// - playlist', 'smart-youtube' ); ?></li>
365
+ <li><?php _e( 'httpvhp:// - HD playlist', 'smart-youtube' ); ?></li>
366
+ <li><?php _e( '[youtube=youtubeadresss] - supported for blogs migrated from wordpress.com', 'smart-youtube' ); ?></li>
367
+ </ul>
368
+ </div>
369
+ <form name="yteform" action="<?php echo $actionurl; ?>" method="post">
370
+ <input type="hidden" name="submitted" value="1" />
371
+ <input type="hidden" id="_wpnonce" name="_wpnonce" value="<?php echo $nonce; ?>" />
372
+ <h2><?php _e( 'Options', 'smart-youtube' ); ?></h2>
373
+ <p><?php _e( 'Smart Youtube is powerful and free WordPress plugin for embeding videos into your blog. ', 'smart-youtube' ); ?></p>
374
+
375
+ <p><?php _e( 'From the same author: <a href="http://managewp.com" target="_blank">ManageWP.com</a> - Wordpress service that helps you manage all your WordPress sites from one location.', 'smart-youtube' ); ?></p>
376
+ <p><?php _e( 'You can adjust the way your embeded youtube videos behave in the options below.', 'smart-youtube' ); ?></p>
377
+ <h3><?php _e( 'Video settings', 'smart-youtube' ); ?></h3>
378
+ <div>
379
+ <input id="check3" type="checkbox" name="disp_posts" <?php echo $disp_posts; ?> />
380
+ <label for="check3"><?php _e( 'Display videos in posts', 'smart-youtube' ); ?></label>
381
+ </div>
382
+ <div>
383
+ <input id="check4" type="checkbox" name="disp_comments" <?php echo $disp_comments; ?> />
384
+ <label for="check4"><?php _e( 'Display videos in comments', 'smart-youtube' ); ?></label>
385
+ </div>
386
+ <br />
387
+ <div>
388
+ <input id="iframe" type="checkbox" name="iframe" <?php echo $iframe; ?> />
389
+ <label for="iframe"><?php _e( 'Use IFRAME embed code', 'smart-youtube' ); ?></label> [<a target="_blank" href="http://apiblog.youtube.com/2010/07/new-way-to-embed-youtube-videos.html">?</a>]
390
+ </div>
391
+ <h3><?php _e( 'Video Appearence', 'smart-youtube' ); ?></h3>
392
+ <p class="instruct">
393
+ <?php _e( 'Video template. Default is just {video}.', 'smart-youtube' ); ?><br />
394
+ <?php echo __( 'You can try <code>', 'smart-youtube' ) . $example . __( '</code> if you want the text to wrap around video.', 'smart-youtube' ); ?>
395
+ </p>
396
+ <textarea cols="50" id="disp_template" name="disp_template"><?php echo $disp_template; ?></textarea>
397
+ <br />
398
+ <input id="http" type="checkbox" name="http" <?php echo $http; ?> />
399
+ <label for="http"><?php _e( 'Parse links with http:// prefix same as httpv://', 'smart-youtube' ); ?></label>
400
+ <br />
401
+ <input id="www" type="checkbox" name="www" <?php echo $www; ?> />
402
+ <label for="www"><?php _e( 'Parse links without http:// prefix', 'smart-youtube' ); ?></label>
403
+ <p class="instruct"><?php _e( 'Video width and height in normal mode (httpv://). Default is 425x344.', 'smart-youtube' ); ?></p>
404
+ <div id="inputSizeNormal">
405
+ <input class="width" name="disp_width" value="<?php echo $disp_width; ?>" size="7"/>x<input class="height" name="disp_height" value="<?php echo $disp_height; ?>" size="7" />
406
+ </div>
407
+ <div class="size-chooser" forDiv="inputSizeNormal">
408
+ <a v-width="320" v-height="265" href="#">
409
+ <span></span>
410
+ <div class="outer">
411
+ <div></div>
412
+ </div>
413
+ </a>
414
+ <a v-width="425" v-height="344" href="#">
415
+ <span></span>
416
+ <div class="outer">
417
+ <div></div>
418
+ </div>
419
+ </a>
420
+ <a v-width="480" v-height="385" href="#">
421
+ <span></span>
422
+ <div class="outer">
423
+ <div></div>
424
+ </div>
425
+ </a>
426
+ <a v-width="640" v-height="505" href="#">
427
+ <span></span>
428
+ <div class="outer">
429
+ <div></div>
430
+ </div>
431
+ </a>
432
+ <a v-width="960" v-height="745" href="#">
433
+ <span></span>
434
+ <div class="outer">
435
+ <div></div>
436
+ </div>
437
+ </a>
438
+ <br clear="both" />
439
+ </div>
440
+ <p class="instruct"><?php _e( 'Video width and height in <strong>high quality</strong> mode (httpvh://). Default is 480x295.', 'smart-youtube' ); ?></p>
441
+ <div id="inputSizeHQ">
442
+ <input class="width" name="disp_widthhq" value="<?php echo $disp_widthhq; ?>" size="7" />x<input class="height" name="disp_heighthq" value="<?php echo $disp_heighthq; ?>" size="7" />
443
+ </div>
444
+ <div class="size-chooser" forDiv="inputSizeHQ">
445
+ <a v-width="480" v-height="295" href="#">
446
+ <span></span>
447
+ <div class="outer">
448
+ <div></div>
449
+ </div>
450
+ </a>
451
+ <a v-width="560" v-height="340" href="#">
452
+ <span></span>
453
+ <div class="outer">
454
+ <div></div>
455
+ </div>
456
+ </a>
457
+ <a v-width="640" v-height="385" href="#">
458
+ <span></span>
459
+ <div class="outer">
460
+ <div></div>
461
+ </div>
462
+ </a>
463
+ <a v-width="853" v-height="505" href="#">
464
+ <span></span>
465
+ <div class="outer">
466
+ <div></div>
467
+ </div>
468
+ </a>
469
+ <a v-width="1280" v-height="745" href="#">
470
+ <span></span>
471
+ <div class="outer">
472
+ <div></div>
473
+ </div>
474
+ </a>
475
+ <br clear="both" />
476
+ </div>
477
+ <p class="instruct"><?php _e( 'Video width and height in <strong>sidebar</strong> mode (regardless of quality). Default is 150x125.', 'smart-youtube' ); ?></p>
478
+ <input id="disp_widthside" name="disp_widthside" value="<?php echo $disp_widthside; ?>" size="7" />x<input id="disp_heightside" name="disp_heightside" value="<?php echo $disp_heightside; ?>" size="7" /><br /><br />
479
+ <div id="watch-customize-embed-form">
480
+ <input type="radio" <?php echo $disp_rel; ?> id="embedCustomization1" name="embedRel" value="1"/>
481
+ <label for="embedCustomization1"><?php _e( 'Include related videos', 'smart-youtube' ); ?></label>
482
+ <br/>
483
+ <input type="radio" <?php echo $disp_rel2; ?> id="embedCustomization0" name="embedRel" value="0"/>
484
+ <label for="embedCustomization0"><?php _e( 'Do not include related videos', 'smart-youtube' ); ?></label>
485
+ <br/>
486
+ </div>
487
+ <br/>
488
+ <div style="margin: 0 0 0 4px; clear: both;">
489
+ <input type="checkbox" id="autoplay_checkbox" name="autoplay" <?php echo $disp_autoplay; ?> /><label for="autoplay_checkbox"><?php _e( 'Autoplay videos', 'smart-youtube' ); ?></label><br />
490
+ <input type="checkbox" id="autoplay_first_checkbox" name="autoplay_first" <?php echo $disp_autoplay_first; ?> /><label for="autoplay_first_checkbox"><?php _e( 'Autoplay only first video on page', 'smart-youtube' ); ?></label><br />
491
+ <input type="checkbox" id="loop_checkbox" name="loop" <?php echo $disp_loop; ?> /><label for="loop_checkbox"><?php _e( 'Loop videos', 'smart-youtube' ); ?></label><br />
492
+ <input type="checkbox" id="disp_search" name="disp_search" <?php echo $disp_search; ?> /><label for="disp_search"><?php _e( 'Display search box', 'smart-youtube' ); ?></label><br />
493
+ <input type="checkbox" id="thumb_checkbox" name="thumb" <?php echo $thumb; ?> /><label for="thumb_checkbox"><?php _e( 'Display thumbnails on home/archive pages', 'smart-youtube' ); ?></label><br />
494
+ <input type="checkbox" id="cbox_checkbox" name="colorbox" <?php echo $colorbox; ?> /><label for="cbox_checkbox"><?php _e( 'Show video in colorbox', 'smart-youtube' ); ?></label><br />
495
+ <input type="checkbox" id="disp_info" name="disp_info" <?php echo $disp_info; ?> /><label for="disp_info"><?php _e( 'Remove Titles & Ratings', 'smart-youtube' ); ?></label><br />
496
+ <input type="checkbox" id="disp_ann" name="disp_ann" <?php echo $disp_ann; ?> /><label for="disp_ann"><?php _e( 'Remove Annotations', 'smart-youtube' ); ?></label><br />
497
+ <input type="checkbox" id="logoless" name="logoless" <?php echo $logoless; ?> /><label for="logoless"><?php _e( 'Hide YouTube Logo', 'smart-youtube' ); ?></label><br />
498
+ <label for="theme"><?php _e( 'Theme (YouTube only):', 'smart-youtube' ); ?></label>
499
+ <select id="theme" name="theme" />
500
+ <option value="dark" <?php echo ( ( $theme == 'dark' ) ? 'selected="yes"' : '' ); ?>><?php _e( 'Dark', 'smart-youtube' ); ?></option>
501
+ <option value="light" <?php echo ( ( $theme == 'light' ) ? 'selected="yes"' : '' ); ?>><?php _e( 'Light', 'smart-youtube' ); ?></option>
502
+ </select><br />
503
+ <input type="checkbox" id="privacy" name="disp_privacy" <?php echo $disp_privacy; ?> /><label for="privacy"><?php _e( 'Enable privacy-enhanced mode', 'smart-youtube' ); ?> [<a target="_blank" href="http://www.google.com/support/youtube/bin/answer.py?answer=141046">?</a>] <?php _e( 'videos may not work for Iphone users)', 'smart-youtube' ); ?></label><br />
504
+ <div id="disp_excerpt_div">
505
+ <label for="disp_excerpt"><?php _e( 'Show embeds in post excerpts as', 'smart-youtube' ); ?></label>
506
+ <select id="disp_excerpt" name="excerpt">
507
+ <option value="vid" <?php echo ( ( $excerpt == 'vid' ) ? 'selected="yes"' : '' ); ?>><?php _e( 'Video', 'smart-youtube' ); ?></option>
508
+ <option value="thm" <?php echo ( ( $excerpt == 'thm' ) ? 'selected="yes"' : '' ); ?>><?php _e( 'Thumbnail', 'smart-youtube' ); ?></option>
509
+ <option value="not" <?php echo ( ( $excerpt == 'not' ) ? 'selected="yes"' : '' ); ?>><?php _e( 'Nothing', 'smart-youtube' ); ?></option>
510
+ </select>
511
+ </div>
512
+ <div id="disp_excerpt_align_div">
513
+ <label for="disp_excerpt_align"><?php _e( 'Align embeds in post excerpts to', 'smart-youtube' ); ?></label>
514
+ <select id="disp_excerpt_align" name="excerpt_align">
515
+ <option value="left" <?php echo ( ( $excerpt_align == 'left' ) ? 'selected="yes"' : '' ); ?>><?php _e( 'Left', 'smart-youtube' ); ?></option>
516
+ <option value="right" <?php echo ( ( $excerpt_align == 'right' ) ? 'selected="yes"' : '' ); ?>><?php _e( 'Right', 'smart-youtube' ); ?></option>
517
+ </select>
518
+ </div>
519
+ </div>
520
+ <h3><?php _e( 'Custom code compatibility', 'smart-youtube' ); ?></h3>
521
+ <p><?php _e( 'Use this option if you have used another youtube plugin and switched over to Smart Youtube.', 'smart-youtube' ); ?><p>
522
+ <p><?php _e( 'For example if you used [yt]qYWWBwf2wHE[/yt] type of code, you would type yt in the box below.', 'smart-youtube' ); ?></p>
523
+ <input id="tag" type="text" name="tag" value="<?php echo $tag; ?>" />
524
+ <label for="tag"><?php _e( 'Custom code', 'smart-youtube' ); ?></label>
525
+
526
+ <h3><?php _e( 'WiziApp support', 'smart-youtube' ); ?></h3>
527
+ <p><?php _e( 'This will integrate your video seamlessly with WiziApp', 'smart-youtube' ); ?></p>
528
+ <input id="wiziapp" type="checkbox" name="wiziapp" <?php echo $wiziapp; ?> />
529
+ <label for="wiziapp"><?php _e( 'Enable WiziApp support', 'smart-youtube' ); ?></label>
530
+ <h3><?php _e( 'xHTML validation', 'smart-youtube' ); ?></h3>
531
+ <p class="instruct"><?php _e( 'Enabling the option below will change default YouTube code to be xHTML valid. (videos may not work for Iphone users)', 'smart-youtube' ); ?></p>
532
+ <input id="valid" type="checkbox" name="valid" <?php echo $valid; ?> />
533
+ <label for="valid"><?php _e( 'Enable xHTML Validation', 'smart-youtube' ); ?></label>
534
+ <h3><?php _e( 'RSS feed options', 'smart-youtube' ); ?></h3>
535
+ <p class="instruct"><?php _e( '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.', 'smart-youtube' ); ?></p>
536
+ <p class="instruct"><?php _e( '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.', 'smart-youtube' ); ?></p>
537
+ <input id="check2" type="checkbox" name="disp_link" <?php echo $disp_link; ?> />
538
+ <label for="check2"><?php _e( 'Display video link in RSS feed', 'smart-youtube' ); ?></label><br />
539
+ <input id="check1" type="checkbox" name="disp_img" <?php echo $disp_img; ?> />
540
+ <label for="check1"><?php _e( 'Display video preview image in RSS feed', 'smart-youtube' ); ?></label>
541
+ <div class="submit"><input type="submit" name="Submit" value="<?php _e( 'Update options', 'smart-youtube' ); ?>" /></div>
542
+ </form>
543
+ </div>
544
+ </div>
545
+ </div>
546
+ </div>
547
+ <h5 class="author"><?php _e( 'Another fine WordPress plugin by <a href="http://www.prelovac.com/vladimir/">Vladimir Prelovac', 'smart-youtube' ); ?></a></h5>
548
+ <?php
549
+ }
550
+
551
+ function handle_colorbox_options() {
552
+ if ( isset( $_POST['submitted'] ) ) {
553
+ $this->options['colorbox_theme'] = ( ! isset( $_POST['colorbox_theme'] ) ? '1' : $_POST['colorbox_theme'] );
554
+
555
+ update_option( $this->key, $this->options );
556
+
557
+ $msg_status = __( 'SEO Friendly Images PRO colorbox options saved.', 'smart-youtube' );
558
+
559
+ // Show message
560
+ echo '<div id="message" class="updated fade"><p>' . $msg_status . '</p></div>';
561
+ }
562
+
563
+ $imgpath = $this->plugin_url . '/i';
564
+ $actionurl = stripslashes(htmlentities(strip_tags($_SERVER['REQUEST_URI'])));
565
+
566
+ $this->options = $this->get_options();
567
+ ?>
568
+ <div class="wrap">
569
+ <?php screen_icon(); ?>
570
+ <h2><?php _e( 'Smart YouTube PRO', 'smart-youtube' ); echo '&nbsp;' . $this->local_version; ?></h2>
571
+ <a href="admin.php?page=syt_settings"><?php _e( 'Settings', 'smart-youtube' ); ?></a> &nbsp;|&nbsp; <a href="admin.php?page=syt_colorbox_options"><?php _e( 'Colorbox Options', 'smart-youtube' ); ?></a> &nbsp;|&nbsp; <a href="admin.php?page=syt_about"><?php _e( 'About', 'smart-youtube' ); ?></a>
572
+ <div id="poststuff" style="margin-top:10px;">
573
+ <div id="sideblock" style="float:right;width:270px;margin-left:10px;">
574
+ <iframe width=270 height=800 frameborder="0" src="http://www.prelovac.com/plugin/news.php?id=2&utm_source=plugin&utm_medium=plugin&utm_campaign=SEO%2BFriendly%2BImages%2BPRO"></iframe>
575
+ </div>
576
+ </div>
577
+ <div id="mainblock" class="submit">
578
+ <div class="dbx-content">
579
+ <h2><?php _e( 'Colorbox Options', 'smart-youtube' ); ?></h2>
580
+ <br />
581
+ <form name="sytform" action="<?php echo $actionurl; ?>" method="post">
582
+ <input type="hidden" name="submitted" value="1" />
583
+ <div>
584
+ <label for="colorbox_theme"><?php _e( 'Choose ColorBox theme:', 'smart-youtube' ); ?></label>
585
+ <select id="colorbox_theme" name="colorbox_theme">
586
+ <?php for($i = 1; $i <= 11; $i++): ?>
587
+ <option value="<?php echo $i; ?>" <?php echo ( $this->options['colorbox_theme'] == $i ) ? 'selected="yes"' : ''; ?>><?php echo __( 'Theme ', 'smart-youtube' ) . $i; ?></option>
588
+ <?php endfor; ?>
589
+ </select>
590
+ </div>
591
+ <div>
592
+ <label for="screenshot_image"><?php _e( 'Theme screenshot:', 'smart-youtube' ); ?></label>
593
+ <div id="screenshot_image">
594
+ <img src="<?php echo $this->plugin_url . '/screenshots/screenshot-' . $this->options['colorbox_theme'] . '.jpg'; ?>" />
595
+ </div>
596
+ </div>
597
+ <div style="padding: 1.5em 0;margin: 5px 0;">
598
+ <input type="submit" name="Submit" value="<?php _e( 'Update options', 'smart-youtube' ); ?>" />
599
+ </div>
600
+ </form>
601
+ </div>
602
+ </div>
603
+ <h5><?php _e( 'Another fine WordPress plugin by', 'smart-youtube' ); ?> <a href="http://www.prelovac.com/vladimir/">Vladimir Prelovac</a></h5>
604
+ </div>
605
+ <?php
606
+ }
607
+
608
+ function handle_about() {
609
+ global $wp_version;
610
+
611
+ $upd_msg = "";
612
+
613
+ $actionurl = stripslashes(htmlentities(strip_tags($_SERVER['REQUEST_URI'])));
614
+ $nonce = wp_create_nonce( 'smart-youtube' );
615
+
616
+ $lic_msg = '<p>Welcome to ' . __( 'Smart YouTube PRO', 'smart-youtube' ) . '.</p>';
617
+ ?>
618
+ <div class="wrap">
619
+ <?php screen_icon(); ?>
620
+ <h2><?php _e( 'Smart YouTube PRO', 'smart-youtube' ); echo '&nbsp;' . $this->local_version; ?></h2>
621
+ <a href="admin.php?page=syt_settings"><?php _e( 'Settings', 'smart-youtube' ); ?></a> &nbsp;|&nbsp; <a href="admin.php?page=syt_colorbox_options"><?php _e( 'Colorbox Options', 'smart-youtube' ); ?></a> &nbsp;|&nbsp; <a href="admin.php?page=syt_about"><?php _e( 'About', 'smart-youtube' ); ?></a>
622
+ <div id="poststuff" style="margin-top:10px;">
623
+
624
+ <div id="sideblock" style="float:right;width:270px;margin-left:10px;">
625
+ <iframe width=270 height=800 frameborder="0" src="http://www.prelovac.com/plugin/news.php?id=2&utm_source=plugin&utm_medium=plugin&utm_campaign=SEO%2BFriendly%2BImages%2BPRO"></iframe>
626
+ </div>
627
+ </div>
628
+ <div id="mainblock" class="submit">
629
+ <div class="dbx-content">
630
+ <h2><?php _e( 'About', 'smart-youtube' ); ?></h2>
631
+ <br />
632
+ <form name="STY_about" action="$actionurl" method="post">
633
+ <input type="hidden" id="_wpnonce" name="_wpnonce" value="$nonce" />
634
+ <input type="hidden" name="submitted" value="1" />
635
+ <?php echo $lic_msg; ?>
636
+ <?php echo __( 'Version:', 'smart-youtube' ) . $this->local_version; ?> <?php echo $upd_msg; ?>
637
+ </form>
638
+ </div>
639
+ </div>
640
+ <h5><?php _e( 'Another fine WordPress plugin by', 'smart-youtube' ); ?> <a href="http://www.prelovac.com/vladimir/">Vladimir Prelovac</a></h5>
641
+ </div>
642
+ <?php
643
+ }
644
+
645
+ function mark_first_post_on_archive() {
646
+ if ( is_archive() || is_home() || is_front_page() ) {
647
+ $this->first_post_on_archive = true;
648
+ }
649
+ }
650
+
651
+ /**
652
+ * Looks for Smart Youtube URL(s) in the post content
653
+ * and replace them with proper HTML tags
654
+ *
655
+ * @param mixed $the_content
656
+ * @param mixed $side
657
+ * @return mixed
658
+ */
659
+ function check( $the_content, $side = 0 ) {
660
+ $char_codes = array( '&#215;', '&#8211;' );
661
+ $replacements = array( "x", "--" );
662
+ $the_content = str_replace( $char_codes, $replacements, $the_content );
663
+ $this->first = false;
664
+
665
+ $context = $side ? 'side' : 'post';
666
+
667
+ preg_match_all( "/((http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?youtube\.com\/watch(\?v\=|\/v\/|#!v=)([a-zA-Z0-9\-\_]{11})([^<\s]*))|((http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?youtu\.be\/([a-zA-Z0-9\-\_]{11}))|((http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?metacafe\.com\/watch\/([a-zA-Z0-9\-\_]{7})\/([^<^\/\s]*)([\/])?)|((http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?vimeo\.com\/([a-zA-Z0-9\-\_]{8})([\/])?)|((http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?liveleak\.com\/view(\?i\=)([a-zA-Z0-9\-\_]*))|((http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?facebook\.com\/video\/video.php\?v\=([a-zA-Z0-9\-\_]*))|((http(vp|vhp)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?youtube\.com\/(view_play_list\?p\=|playlist\?list\=)([a-zA-Z0-9\-\_]{18,34})([^<\s]*))/", $the_content, $matches, PREG_SET_ORDER );
668
+
669
+ foreach ( $matches as $match ) {
670
+ if ( $match[1] != '' ) {
671
+ if ( 'on' == $this->options['wiziapp'] ) {
672
+ $videos = array();
673
+ $video_info['src'] = "http://www.youtube.com/watch?v={$match[6]}";
674
+ array_push( $videos, $video_info );
675
+ $replace_text = '';
676
+ $replace_text = apply_filters( 'wiziapp_3rd_party_plugin', $replace_text, 'video', $videos );
677
+ $the_content = str_replace( $match[1], $replace_text, $the_content );
678
+ } else if ( ( $match[2] == 'http://' && $this->options['http'] == 'on' ) || ( $match[2] == '' && $this->options['www'] == 'on' ) ) {
679
+ $the_content = str_replace( $match[1], $this->tag_youtube( $context, $match[6], 'v', $match[7] ), $the_content );
680
+ } else if ( $match[3] == 'v' || $match[3] == 'vh' || $match[3] == 'vhd' ) {
681
+ $the_content = str_replace( $match[1], $this->tag_youtube( $context, $match[6], $match[3], $match[7] ), $the_content );
682
+ }
683
+ } elseif ( $match[8] != '' ) {
684
+ if ( 'on' == $this->options['wiziapp'] ) {
685
+ $videos = array();
686
+ $video_info['src'] = "http://www.youtube.com/watch?v={$match[12]}";
687
+ array_push( $videos, $video_info );
688
+ $replace_text = '';
689
+ $replace_text = apply_filters( 'wiziapp_3rd_party_plugin', $replace_text, 'video', $videos );
690
+ $the_content = str_replace( $match[1], $replace_text, $the_content );
691
+ } else if ( ( $match[9] == 'http://' && $this->options['http'] == 'on' ) || ( $match[9] == '' && $this->options['www'] == 'on' ) ) {
692
+ $the_content = str_replace( $match[8], $this->tag_youtube( $context, $match[12], 'v' ), $the_content );
693
+ } else if ( $match[10] == 'v' || $match[10] == 'vh' || $match[10] == 'vhd' ) {
694
+ $the_content = str_replace( $match[8], $this->tag_youtube( $context, $match[12], $match[10] ), $the_content );
695
+ }
696
+ } elseif ( $match[13] != '' ) {
697
+ if ( 'on' == $this->options['wiziapp'] ) {
698
+ $videos = array();
699
+ $video_info['src'] = "http://www.metacafe.com/watch/{$match[17]}/{$match[18]}/";
700
+ array_push( $videos, $video_info );
701
+ $replace_text = '';
702
+ $replace_text = apply_filters( 'wiziapp_3rd_party_plugin', $replace_text, 'video', $videos );
703
+ $the_content = str_replace( $match[1], $replace_text, $the_content );
704
+ } else if ( ( $match[14] == 'http://' && $this->options['http'] == 'on' ) || ( $match[14] == '' && $this->options['www'] == 'on' ) ) {
705
+ $the_content = str_replace( $match[13], $this->tag_metacafe( $context, $match[17], 'v', $match[18] ), $the_content );
706
+ } else if ( $match[15] == 'v' || $match[15] == 'vh' || $match[15] == 'vhd' ) {
707
+ $the_content = str_replace( $match[13], $this->tag_metacafe( $context, $match[17], $match[15], $match[18] ), $the_content );
708
+ }
709
+ } elseif ( $match[20] != '' ) {
710
+ if ( 'on' == $this->options['wiziapp'] ) {
711
+ $videos = array();
712
+ $video_info['src'] = "http://www.vimeo.com/{$match[24]}";
713
+ array_push( $videos, $video_info );
714
+ $replace_text = '';
715
+ $replace_text = apply_filters( 'wiziapp_3rd_party_plugin', $replace_text, 'video', $videos );
716
+ $the_content = str_replace( $match[1], $replace_text, $the_content );
717
+ } else if ( ( $match[21] == 'http://' && $this->options['http'] == 'on' ) || ( $match[21] == '' && $this->options['www'] == 'on' ) ) {
718
+ $the_content = str_replace( $match[20], $this->tag_vimeo( $context, $match[24], 'v' ), $the_content );
719
+ } else if ( $match[22] == 'v' || $match[22] == 'vh' || $match[22] == 'vhd' ) {
720
+ $the_content = str_replace( $match[20], $this->tag_vimeo( $context, $match[24], $match[22] ), $the_content );
721
+ }
722
+ } elseif ( $match[26] != '' ) {
723
+ if ( 'on' == $this->options['wiziapp'] ) {
724
+ $videos = array();
725
+ $video_info['src'] = "http://www.liveleak.com/view?i={$match[31]}";
726
+ array_push( $videos, $video_info );
727
+ $replace_text = '';
728
+ $replace_text = apply_filters( 'wiziapp_3rd_party_plugin', $replace_text, 'video', $videos );
729
+ $the_content = str_replace( $match[1], $replace_text, $the_content );
730
+ } else if ( ( $match[27] == 'http://' && $this->options['http'] == 'on' ) || ( $match[27] == '' && $this->options['www'] == 'on' ) ) {
731
+ $the_content = str_replace( $match[26], $this->tag_liveleak( $context, $match[31], 'v' ), $the_content );
732
+ } else if ( $match[28] == 'v' || $match[28] == 'vh' || $match[28] == 'vhd' ) {
733
+ $the_content = str_replace( $match[26], $this->tag_liveleak( $context, $match[31], $match[28] ), $the_content );
734
+ }
735
+ } elseif ( $match[32] != '' ) {
736
+ if ( 'on' == $this->options['wiziapp'] ) {
737
+ $videos = array();
738
+ $video_info['src'] = "http://www.facebook.com/video/video.php?v={$match[36]}";
739
+ array_push( $videos, $video_info );
740
+ $replace_text = '';
741
+ $replace_text = apply_filters( 'wiziapp_3rd_party_plugin', $replace_text, 'video', $videos );
742
+ $the_content = str_replace( $match[1], $replace_text, $the_content );
743
+ } else if ( ( $match[33] == 'http://' && $this->options['http'] == 'on' ) || ( $match[33] == '' && $this->options['www'] == 'on' ) ) {
744
+ $the_content = str_replace( $match[32], $this->tag_facebook( $context, $match[36], 'v' ), $the_content );
745
+ } else if ( $match[34] == 'v' || $match[34] == 'vh' || $match[34] == 'vhd' ) {
746
+ $the_content = str_replace( $match[32], $this->tag_facebook( $context, $match[36], $match[34] ), $the_content );
747
+ }
748
+ } elseif ( $match[37] != '' ) {
749
+
750
+ if ( 'on' == $this->options['wiziapp'] ) {
751
+ $videos = array();
752
+ $video_info['src'] = "http://www.youtube.com/playlist?list={$match[42]}";
753
+ array_push( $videos, $video_info );
754
+ $replace_text = '';
755
+ $replace_text = apply_filters( 'wiziapp_3rd_party_plugin', $replace_text, 'video', $videos );
756
+ $the_content = str_replace( $match[1], $replace_text, $the_content );
757
+ } else if ( ( $match[38] == 'http://' && $this->options['http'] == 'on' ) || ( $match[38] == '' && $this->options['www'] == 'on' ) ) {
758
+ $the_content = str_replace( $match[37], $this->tag_youtube( $context, $match[42], 'vp', $match[43] ), $the_content );
759
+ } else if ( $match[39] == 'vp' || $match[39] == 'vhp' ) {
760
+ $the_content = str_replace( $match[37], $this->tag_youtube( $context, $match[42], $match[39], $match[43] ), $the_content );
761
+ }
762
+ }
763
+ }
764
+
765
+ /*preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?youtu\.be\/([a-zA-Z0-9\-\_]{11})/", $the_content, $matches, PREG_SET_ORDER );
766
+ foreach ( $matches as $match ) {
767
+ if (( $match[1] == 'http://' && $this->options['http'] == 'on' ) || ( $match[1] == '' && $this->options['www'] == 'on' ) ) {
768
+ $the_content = str_replace( $match[0], $this->tag_youtube( $context, $match[4], 'v' ), $the_content );
769
+ } else if ( $match[2] == 'v' || $match[2] == 'vh' || $match[2] == 'vhd' ) {
770
+ $the_content = str_replace( $match[0], $this->tag_youtube( $context, $match[4], $match[2] ), $the_content );
771
+ }
772
+ }
773
+
774
+ preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?metacafe\.com\/watch\/([a-zA-Z0-9\-\_]{7})\/([^<^\/\s]*)([\/])?/", $the_content, $matches, PREG_SET_ORDER );
775
+ foreach ( $matches as $match ) {
776
+ if ( ( $match[1] == 'http://' && $this->options['http'] == 'on' ) || ( $match[1] == '' && $this->options['www'] == 'on' ) ) {
777
+ $the_content = str_replace( $match[0], $this->tag_metacafe( $context, $match[4], 'v', $match[5] ), $the_content );
778
+ } else if ( $match[2] == 'v' || $match[2] == 'vh' || $match[2] == 'vhd' ) {
779
+ $the_content = str_replace( $match[0], $this->tag_metacafe( $context, $match[4], $match[2], $match[5] ), $the_content );
780
+ }
781
+ }
782
+
783
+ preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?vimeo\.com\/([a-zA-Z0-9\-\_]{8})([\/])?/", $the_content, $matches, PREG_SET_ORDER );
784
+ foreach ( $matches as $match ) {
785
+ if ( ( $match[1] == 'http://' && $this->options['http'] == 'on' ) || ( $match[1] == '' && $this->options['www'] == 'on' ) ) {
786
+ $the_content = str_replace( $match[0], $this->tag_vimeo( $context, $match[4], 'v' ), $the_content );
787
+ } else if ( $match[2] == 'v' || $match[2] == 'vh' || $match[2] == 'vhd' ) {
788
+ $the_content = str_replace( $match[0], $this->tag_vimeo( $context, $match[4], $match[2] ), $the_content );
789
+ }
790
+ }
791
+
792
+ preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?liveleak\.com\/view(\?i\=)([a-zA-Z0-9\-\_]*)/", $the_content, $matches, PREG_SET_ORDER );
793
+ foreach ( $matches as $match ) {
794
+ if ( ( $match[1] == 'http://' && $this->options['http'] == 'on' ) || ( $match[1] == '' && $this->options['www'] == 'on' ) ) {
795
+ $the_content = str_replace( $match[0], $this->tag_liveleak( $context, $match[5], 'v' ), $the_content );
796
+ } else if ( $match[2] == 'v' || $match[2] == 'vh' || $match[2] == 'vhd' ) {
797
+ $the_content = str_replace( $match[0], $this->tag_liveleak( $context, $match[5], $match[2] ), $the_content );
798
+ }
799
+ }
800
+
801
+ preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?facebook\.com\/video\/video.php\?v\=([a-zA-Z0-9\-\_]*)/", $the_content, $matches, PREG_SET_ORDER );
802
+ foreach ( $matches as $match ) {
803
+ if ( ( $match[1] == 'http://' && $this->options['http'] == 'on' ) || ( $match[1] == '' && $this->options['www'] == 'on' ) ) {
804
+ $the_content = str_replace( $match[0], $this->tag_facebook( $context, $match[4], 'v' ), $the_content );
805
+ } else if ( $match[2] == 'v' || $match[2] == 'vh' || $match[2] == 'vhd' ) {
806
+ $the_content = str_replace( $match[0], $this->tag_facebook( $context, $match[4], $match[2] ), $the_content );
807
+ }
808
+ }
809
+
810
+ preg_match_all( "/(http(vp|vhp)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?youtube\.com\/view_play_list(\?p\=|\/v\/|#!v=)([a-zA-Z0-9\-\_]{16})([^<\s]*)/", $the_content, $matches, PREG_SET_ORDER );
811
+ foreach ( $matches as $match ) {
812
+ if ( ( $match[1] == 'http://' && $this->options['http'] == 'on' ) || ( $match[1] == '' && $this->options['www'] == 'on' ) ) {
813
+ $the_content = str_replace( $match[0], $this->tag_youtube( $context, $match[5], 'vp', $match[6] ), $the_content );
814
+ } else if ( $match[2] == 'vp' || $match[2] == 'vhp' ) {
815
+ $the_content = str_replace( $match[0], $this->tag_youtube( $context, $match[5], $match[2], $match[6] ), $the_content );
816
+ }
817
+ }*/
818
+
819
+ // to work with migrated blogs from Wordpress.com replacing [youtube=youtubeadresss]
820
+ if ( strpos($the_content, "[youtube") !== false ) {
821
+ 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 );
822
+ foreach ( $matches as $match ) {
823
+ $the_content = preg_replace( "/\[youtube\=http:\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/watch(\?v\=|\/v\/|#!v=)([a-zA-Z0-9\-\_]{11})([^\s<]*)\]/", $this->tag_youtube( $context, $match[3], '', $match[4] ), $the_content, 1 );
824
+ }
825
+ }
826
+ $tag = $this->options['tag'];
827
+
828
+ if ( $tag != '' && strpos( $the_content, "[".$tag."]" ) !== false ) {
829
+ preg_match_all( "/\[$tag\]([a-zA-Z0-9\-\_]{11})([^<\s]*)\[\/$tag\]/", $the_content, $matches, PREG_SET_ORDER );
830
+ foreach ( $matches as $match ) {
831
+ $the_content = preg_replace( "/\[$tag\]([a-zA-Z0-9\-\_]{11})([^<\s]*)\[\/$tag\]/", $this->tag_youtube( $context, $match[1], '', '' ), $the_content, 1 );
832
+ }
833
+ }
834
+
835
+ if ( $this->first_post_on_archive ) {
836
+ $this->first_post_on_archive = false;
837
+ }
838
+
839
+ return $the_content;
840
+ }
841
+
842
+ function check_excerpt( $the_content ) {
843
+ $excerpt = $this->options['excerpt'];
844
+ $template = trim($this->options['template']) == '' ? '{video}' : $this->options['template'];
845
+
846
+ if ( $excerpt != 'not' ) {
847
+ global $post;
848
+ $content = $post->post_content;
849
+
850
+ preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?youtube\.com\/watch(\?v\=|\/v\/|#!v=)([a-zA-Z0-9\-\_]{11})([^<\s]*)/", $content, $matches['youtube.com'], PREG_SET_ORDER );
851
+ preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?youtu\.be\/([a-zA-Z0-9\-\_]{11})/", $content, $matches['youtu.be'], PREG_SET_ORDER );
852
+ preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?metacafe\.com\/watch\/([a-zA-Z0-9\-\_]{7})\/([^<^\/\s]*)([\/])?/", $content, $matches['metacafe.com'], PREG_SET_ORDER );
853
+ preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?vimeo\.com\/([a-zA-Z0-9\-\_]{8})([\/])?/", $content, $matches['vimeo.com'], PREG_SET_ORDER );
854
+ preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?liveleak\.com\/view(\?i\=)([a-zA-Z0-9\-\_]*)/", $content, $matches['liveleak.com'], PREG_SET_ORDER );
855
+ preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?facebook\.com\/video\/video.php\?v\=([a-zA-Z0-9\-\_]*)/", $content, $matches['facebook.com'], PREG_SET_ORDER );
856
+
857
+ if ( isset( $matches['youtube.com'][0] ) ) {
858
+ if ( ( $matches['youtube.com'][0][1] == 'http://' && $this->options['http'] == 'on' ) || ( $matches['youtube.com'][0][1] == '' && $this->options['www'] == 'on' ) ) {
859
+ $matches['youtube.com'][0][0] = str_replace( $matches['youtube.com'][0][0], $this->tag_youtube( 'excerpt', $matches['youtube.com'][0][5], 'v', $matches['youtube.com'][0][6] ), $matches['youtube.com'][0][0] );
860
+ } else if ( $matches['youtube.com'][0][2] == 'v' || $matches['youtube.com'][0][2] == 'vh' || $matches['youtube.com'][0][2] == 'vhd' ) {
861
+ $matches['youtube.com'][0][0] = str_replace( $matches['youtube.com'][0][0], $this->tag_youtube( 'excerpt', $matches['youtube.com'][0][5], $matches['youtube.com'][0][2], $matches['youtube.com'][0][6] ), $matches['youtube.com'][0][0] );
862
+ }
863
+ $result = $matches['youtube.com'][0][0];
864
+ } else if ( isset( $matches['youtu.be'][0] ) ) {
865
+ if ( ( $matches['youtu.be'][0][1] == 'http://' && $this->options['http'] == 'on' ) || ( $matches['youtu.be'][0][1] == '' && $this->options['www'] == 'on' ) ) {
866
+ $matches['youtu.be'][0][0] = str_replace( $matches['youtu.be'][0][0], $this->tag_youtube( 'excerpt', $matches['youtu.be'][0][4], 'v' ), $matches['youtu.be'][0][0] );
867
+ } else if ( $matches['youtu.be'][0][2] == 'v' || $matches['youtu.be'][0][2] == 'vh' || $matches['youtu.be'][0][2] == 'vhd' ) {
868
+ $matches['youtu.be'][0][0] = str_replace( $matches['youtu.be'][0][0], $this->tag_youtube( 'excerpt', $matches['youtu.be'][0][4], $matches['youtu.be'][0][2]), $matches['youtu.be'][0][0] );
869
+ }
870
+ $result = $matches['youtu.be'][0][0];
871
+ } else if ( isset( $matches['metacafe.com'][0] ) ) {
872
+ if ( ( $matches['metacafe.com'][0][1] == 'http://' && $this->options['http'] == 'on' ) || ( $matches['metacafe.com'][0][1] == '' && $this->options['www'] == 'on' ) ) {
873
+ $matches['metacafe.com'][0][0] = str_replace( $matches['metacafe.com'][0][0], $this->tag_metacafe( 'excerpt', $matches['metacafe.com'][0][4], 'v', $matches['metacafe.com'][0][5] ), $matches['metacafe.com'][0][0] );
874
+ } else if ( $matches['metacafe.com'][0][2] == 'v' || $matches['metacafe.com'][0][2] == 'vh' || $matches['metacafe.com'][0][2] == 'vhd' ) {
875
+ $matches['metacafe.com'][0][0] = str_replace( $matches['metacafe.com'][0][0], $this->tag_metacafe( 'excerpt', $matches['metacafe.com'][0][4], $matches['metacafe.com'][0][2], $matches['metacafe.com'][0][5] ), $matches['metacafe.com'][0][0] );
876
+ }
877
+ $result = $matches['metacafe.com'][0][0];
878
+ } else if ( isset($matches['vimeo.com'][0] ) ) {
879
+ if ( ( $matches['vimeo.com'][0][1] == 'http://' && $this->options['http'] == 'on' ) || ( $matches['vimeo.com'][0][1] == '' && $this->options['www'] == 'on' ) ) {
880
+ $matches['vimeo.com'][0][0] = str_replace( $matches['vimeo.com'][0][0], $this->tag_vimeo( 'excerpt', $matches['vimeo.com'][0][4], 'v' ), $matches['vimeo.com'][0][0] );
881
+ }
882
+ else if ( $matches['vimeo.com'][0][2] == 'v' || $matches['vimeo.com'][0][2] == 'vh' || $matches['vimeo.com'][0][2] == 'vhd' ) {
883
+ $matches['vimeo.com'][0][0] = str_replace( $matches['vimeo.com'][0][0], $this->tag_vimeo( 'excerpt', $matches['vimeo.com'][0][4], $matches['vimeo.com'][0][2] ), $matches['vimeo.com'][0][0] );
884
+ }
885
+ $result = $matches['vimeo.com'][0][0];
886
+ } else if ( isset( $matches['liveleak.com'][0] ) ) {
887
+ if ( ( $matches['liveleak.com'][0][1] == 'http://' && $this->options['http'] == 'on' ) || ( $matches['liveleak.com'][0][1] == '' && $this->options['www'] == 'on' ) ) {
888
+ $matches['liveleak.com'][0][0] = str_replace( $matches['liveleak.com'][0][0], $this->tag_liveleak( 'excerpt', $matches['liveleak.com'][0][4], 'v' ), $matches['liveleak.com'][0][0] );
889
+ } else if ( $matches['liveleak.com'][0][2] == 'v' || $matches['liveleak.com'][0][2] == 'vh' || $matches['liveleak.com'][0][2] == 'vhd' ) {
890
+ $matches['liveleak.com'][0][0] = str_replace( $matches['liveleak.com'][0][0], $this->tag__liveleak( 'excerpt', $matches['liveleak.com'][0][4], $matches['liveleak.com'][0][2] ), $matches['liveleak.com'][0][0] );
891
+ }
892
+ $result = $matches['liveleak.com'][0][0];
893
+ } else if ( isset( $matches['facebook.com'][0] ) ) {
894
+ if ( ( $matches['facebook.com'][0][1] == 'http://' && $this->options['http'] == 'on' ) || ( $matches['facebook.com'][0][1] == '' && $this->options['www'] == 'on' ) ) {
895
+ $matches['facebook.com'][0][0] = str_replace( $matches['facebook.com'][0][0], $this->tag_facebook( 'excerpt', $matches['facebook.com'][0][4], 'v' ), $matches['facebook.com'][0][0] );
896
+ } else if ( $matches['facebook.com'][0][2] == 'v' || $matches['facebook.com'][0][2] == 'vh' || $matches['facebook.com'][0][2] == 'vhd' ) {
897
+ $matches['facebook.com'][0][0] = str_replace( $matches['facebook.com'][0][0], $this->tag_facebook( 'excerpt', $matches['facebook.com'][0][4], $matches['facebook.com'][0][2] ), $matches['facebook.com'][0][0] );
898
+ }
899
+ $result = $matches['facebook.com'][0][0];
900
+ } else {
901
+ /*$width = $this->options['widthside'];
902
+ $height = $this->options['heightside'];
903
+
904
+ $img_url = htmlspecialchars( $this->plugin_url . '/img/default.jpg' );
905
+ $post_url = get_permalink( $post->ID );
906
+ $yte_tag = <<<EOT
907
+ <a href="$post_url">
908
+ <img src="$img_url" height="$height" width="$width" />
909
+ </a>
910
+ EOT;
911
+ $result = str_replace( '{video}', $yte_tag, html_entity_decode( $template ) );*/
912
+
913
+ return $the_content;
914
+ }
915
+ if ( isset( $result ) ) {
916
+ $the_content = '<div style="float:' . $this->options["excerpt_align"] . ';padding-' . ( $this->options["excerpt_aign"] == 'left' ? 'right' : 'left' ) . ':10px;">' . $result . '</div>' . $the_content . '<div style="clear:both"></div>';
917
+ }
918
+ }
919
+
920
+ if ( $this->first_post_on_archive ) {
921
+ $this->first_post_on_archive = false;
922
+ }
923
+
924
+ return $the_content;
925
+ }
926
+
927
+ function tag_youtube( $context, $file, $high = 'v', $time = '' ) {
928
+ $playlist = 0;
929
+ $disp_rel = $this->options['rel'];
930
+ $autoplay = $this->options['autoplay'];
931
+ $autoplay_first = $this->options['autoplay_first'];
932
+ $disp_search = $this->options['search'] == 'on' ? 1 : 0;
933
+ $disp_info = $this->options['info'] == 'on' ? '&showinfo=0' : '';
934
+ $disp_ann = $this->options['ann'] == 'on' ? '&iv_load_policy=3' : '';
935
+ $template = trim( $this->options['template'] ) == '' ? '{video}' : $this->options['template'];
936
+ $valid = $this->options['valid'];
937
+ if ($this->options['loop'])
938
+ $loop="&loop=1&playlist=$file";
939
+ else $loop='';
940
+ $thumb = $this->options['thumb'];
941
+ $colorbox = $this->options['colorbox'];
942
+ $logoless = $this->options['logoless'];
943
+ $theme = $this->options['theme'];
944
+ $excerpt = $this->options['excerpt'];
945
+
946
+ switch ( $high ) {
947
+ case 'v':
948
+ $high = '';
949
+ break;
950
+ case 'vh':
951
+ $high = '&amp;hd=1';
952
+ break;
953
+ case 'vhd':
954
+ $high = '&amp;hd=1';
955
+ break;
956
+ case 'vp':
957
+ $high = '';
958
+ $playlist = 1;
959
+ break;
960
+ case 'vhp':
961
+ $high = '&amp;hd=1';
962
+ $playlist = 1;
963
+ break;
964
+ default:
965
+ $high = '';
966
+ break;
967
+ }
968
+
969
+ $width = ( $context == 'excerpt' || $context == 'side' ) ?
970
+ $this->options['widthside'] :
971
+ ( $high ? $this->options['widthhq'] : $this->options['width'] );
972
+
973
+ $height = ( $context == 'excerpt' || $context == 'side' ) ?
974
+ $this->options['heightside'] :
975
+ ( $high ? $this->options['heighthq'] : $this->options['height'] );
976
+
977
+ if ( ! $width ) {
978
+ $width = ! $high ? 480 : 425 ;
979
+ }
980
+
981
+ if ( ! $height ) {
982
+ $height = ! $high ? 360 : 344;
983
+ }
984
+
985
+ $ap = '';
986
+ if ( is_single() ) {
987
+ if ( $context == 'post' && $autoplay_first && ! $this->first ) {
988
+ $ap = '&autoplay=1';
989
+ $this->first = true;
990
+ } else if ( ( $context == 'post' && $autoplay && ! $autoplay_first ) || ( $context == 'excerpt' && $autoplay ) ) {
991
+ $ap = '&autoplay=1';
992
+ } else {
993
+ $ap = '';
994
+ }
995
+ } elseif ( $this->first_post_on_archive ) {
996
+ if ( $context == 'post' && $autoplay_first && ! $this->first ) {
997
+ $ap = '&autoplay=1';
998
+ $this->first = true;
999
+ } else if ( ( $context == 'post' && $autoplay && ! $autoplay_first ) || ( $context == 'excerpt' && $autoplay ) ) {
1000
+ $ap = '&autoplay=1';
1001
+ } else {
1002
+ $ap = '';
1003
+ }
1004
+ }
1005
+
1006
+ if ( $logoless == 'on' ) {
1007
+ $ll = '&modestbranding=1';
1008
+ $disp_info = '';
1009
+ } else {
1010
+ $ll = '';
1011
+ }
1012
+
1013
+ $root_url = $this->options['privacy'] ? 'http://www.youtube-nocookie.com' : 'http://www.youtube.com';
1014
+
1015
+ if ( $excerpt == 'thm' ) {
1016
+ $img_url = htmlspecialchars( "http://img.youtube.com/vi/$file/0.jpg" );
1017
+ global $post;
1018
+ $post_url = get_permalink( $post->ID );
1019
+ $yte_tag = <<<EOT
1020
+ <a href="$post_url"><img src="$img_url" height="$height" width="$width" /></a>
1021
+ EOT;
1022
+ }
1023
+
1024
+ if ( ( ( is_home() || is_front_page() || is_archive() ) && $context == 'post' && $thumb == 'on' ) || ( $context == 'thumb' ) || ( $context == 'excerpt' && $excerpt == 'thm' ) ) {
1025
+ $img_url = htmlspecialchars( "http://img.youtube.com/vi/$file/0.jpg" );
1026
+ if ( $context == 'excerpt' && $excerpt == 'thm' ) {
1027
+ global $post;
1028
+ $post_url = get_permalink( $post->ID );
1029
+ $yte_tag = <<<EOT
1030
+ <a href="$post_url"><img src="$img_url" height="$height" width="$width" /></a>
1031
+ EOT;
1032
+ } else {
1033
+ $yte_tag = <<<EOT
1034
+ <img src="$img_url" height="$height" width="$width" />
1035
+ EOT;
1036
+ }
1037
+ } else {
1038
+ if ( $this->options['iframe'] == 'on' )
1039
+ $video_url = htmlspecialchars( "$root_url/embed/$file?wmode=transparent&fs=1&hl=en$ap$ll$loop{$disp_info}$disp_ann&showsearch=$disp_search&rel=$disp_rel&theme=$theme", ENT_QUOTES ) . $high . $time;
1040
+ else
1041
+ $video_url = htmlspecialchars( "$root_url/v/$file?wmode=transparent&fs=1&hl=en&$ap$ll$loop{$disp_info}$disp_ann&showsearch=$disp_search&rel=$disp_rel&theme=$theme", ENT_QUOTES ) . $high . $time;
1042
+
1043
+ if ( $playlist ) {
1044
+ $video_url = htmlspecialchars( "$root_url/embed/videoseries?list=$file&fs=1&hl=en$ap$ll$loop{$disp_info}$disp_ann&showsearch=$disp_search&rel=$disp_rel&theme=$theme", ENT_QUOTES ) . $high . $time;
1045
+ $yte_tag = <<<EOT
1046
+ <span class="youtube"><iframe class="youtube-player" src="$video_url" width="$width" height="$height" frameborder="0" allowfullscreen></iframe></span>
1047
+ EOT;
1048
+ } elseif ( $valid == 'off' || strpos( $_SERVER['HTTP_USER_AGENT'], 'iPhone' ) === TRUE || strpos( $_SERVER['HTTP_USER_AGENT'], 'iPod' ) === TRUE || strpos( $_SERVER['HTTP_USER_AGENT'], 'iPad' ) === TRUE ) {
1049
+ if ( $context == 'post' && $colorbox == 'on' ) {
1050
+ $img_url = htmlspecialchars( "http://img.youtube.com/vi/$file/0.jpg" );
1051
+ $yte_tag = <<<EOT
1052
+ <a class="colorbox_video" href="$video_url"><img width="$width" height="$height" src="$img_url" /></a></span>
1053
+ EOT;
1054
+ } else if ( $this->options['iframe'] == 'on' )
1055
+ $yte_tag = <<<EOT
1056
+ <span class="youtube"><iframe title="YouTube video player" class="youtube-player" type="text/html" width="$width" height="$height" src="$video_url" frameborder="0" allowfullscreen></iframe></span>
1057
+ EOT;
1058
+ else
1059
+ $yte_tag = <<<EOT
1060
+ <span class="youtube"><object width="$width" height="$height"><param name="movie" value="$video_url" />
1061
+ <param name="allowFullScreen" value="true" /><embed wmode="opaque" src="$video_url" type="application/x-shockwave-flash" allowfullscreen="true" width="$width" height="$height"></embed><param name="wmode" value="opaque" /></object></span>
1062
+ EOT;
1063
+ } else {
1064
+ if ( $context == 'post' && $colorbox == 'on' ) {
1065
+ $img_url = htmlspecialchars( "http://img.youtube.com/vi/$file/0.jpg" );
1066
+ $yte_tag = <<<EOT
1067
+ <a class="colorbox_video" href="$video_url"><img width="$width" height="$height" src="$img_url" /></a></span>
1068
+ EOT;
1069
+ } else if ( $this->options['iframe'] == 'on' ) {
1070
+ $yte_tag = <<<EOT
1071
+ <span class="youtube"><iframe title="YouTube video player" class="youtube-player" type="text/html" width="$width" height="$height" src="$video_url" frameborder="0" allowfullscreen></iframe></span>
1072
+ EOT;
1073
+ } else {
1074
+ $yte_tag = <<<EOT
1075
+ <span class="youtube"><object type="application/x-shockwave-flash" width="$width" height="$height" data="$video_url"><param name="movie" value="$video_url" />
1076
+ <param name="allowFullScreen" value="true" /><param name="wmode" value="transparent" /></object></span>
1077
+ EOT;
1078
+ }
1079
+ }
1080
+ }
1081
+
1082
+ if ( is_feed() && ( $context == 'post' || $context = 'excerpt' ) ) {
1083
+ if ( $high ) {
1084
+ $high = '&fmt=18';
1085
+ }
1086
+ if ( $playlist )
1087
+ $url = 'http://www.youtube.com/playlist?list=';
1088
+ else
1089
+ $url = 'http://www.youtube.com/watch?v=';
1090
+
1091
+ $yte_tag = '';
1092
+ if ( $this->options['link'] == 'on' ) {
1093
+ $yte_tag .= '<p><a href="' . $url . $file . $high . '">'.$url. $file . '</a></p>';
1094
+ }
1095
+
1096
+ if ( $this->options['img'] == 'on' ) {
1097
+ $yte_tag .= '<p><a href="' . $url . $file . $high. '"><img src="http://img.youtube.com/vi/' . $file . '/default.jpg" width="130" height="97" border=0></a></p>';
1098
+ }
1099
+
1100
+ if ($this->options['link'] == 'off' && $this->options['img'] == 'off')
1101
+ $yte_tag=$url.$file;
1102
+ }
1103
+
1104
+ return str_replace( '{video}', $yte_tag, html_entity_decode( $template ) );
1105
+ }
1106
+
1107
+ function tag_metacafe( $context, $file, $high = 'v', $name = '' ) {
1108
+ $width = ( $context == 'excerpt' || $context == 'side' ) ?
1109
+ $this->options['widthside'] :
1110
+ ( $high ? $this->options['widthhq'] : $this->options['width'] );
1111
+
1112
+ $height = ( $context == 'excerpt' || $context == 'side' ) ?
1113
+ $this->options['heightside'] :
1114
+ ( $high ? $this->options['heighthq'] : $this->options['height'] );
1115
+
1116
+ if ( ! $width ) {
1117
+ $width = ! ( $high == 'v' ) ? 480 : 425 ;
1118
+ }
1119
+
1120
+ if ( ! $height ) {
1121
+ $height = ! ( $high == 'v' ) ? 360 : 344;
1122
+ }
1123
+
1124
+ $template = trim( $this->options['template'] ) == '' ? '{video}' : $this->options['template'];
1125
+ $excerpt = $this->options['excerpt'];
1126
+ $thumb = $this->options['thumb'];
1127
+ $colorbox = $this->options['colorbox'];
1128
+ $autoplay = $this->options['autoplay'];
1129
+ $autoplay_first = $this->options['autoplay_first'];
1130
+
1131
+ $ap = 'no';
1132
+ if ( is_single() ) {
1133
+ if ( $context == 'post' && $autoplay_first && ! $this->first ) {
1134
+ $ap = 'yes';
1135
+ $this->first = true;
1136
+ } else if ( ( $context == 'post' && $autoplay && ! $autoplay_first ) || ( $context == 'excerpt' && $autoplay ) ) {
1137
+ $ap = 'yes';
1138
+ } else {
1139
+ $ap = 'no';
1140
+ }
1141
+ } elseif ( $this->first_post_on_archive ) {
1142
+ if ( $context == 'post' && $autoplay_first && ! $this->first ) {
1143
+ $ap = 'yes';
1144
+ $this->first = true;
1145
+ } else if ( ( $context == 'post' && $autoplay && ! $autoplay_first ) || ( $context == 'excerpt' && $autoplay ) ) {
1146
+ $ap = 'yes';
1147
+ } else {
1148
+ $ap = 'no';
1149
+ }
1150
+ }
1151
+
1152
+ $flash_vars = "playerVars=showStats=no|autoPlay=$ap|";
1153
+
1154
+ if ( ( ( is_home() || is_front_page() || is_archive() ) && $context == 'post' && $thumb == 'on' ) || ( $context == 'thumb' ) || ( $context == 'excerpt' && $excerpt == 'thm' ) ) {
1155
+ $img_url = htmlspecialchars( "http://www.metacafe.com/thumb/$file.jpg" );
1156
+ if ( $context == 'excerpt' && $excerpt == 'thm' ) {
1157
+ global $post;
1158
+ $post_url = get_permalink( $post->ID );
1159
+ $yte_tag = <<<EOT
1160
+ <a href="$post_url"><img src="$img_url" height="$height" width="$width" /></a>
1161
+ EOT;
1162
+ } else {
1163
+ $yte_tag = <<<EOT
1164
+ <img src="$img_url" height="$height" width="$width" />
1165
+ EOT;
1166
+ }
1167
+ } else if ( $context == 'post' && $colorbox == 'on' ) {
1168
+ $img_url = htmlspecialchars( "http://www.metacafe.com/thumb/$file.jpg" );
1169
+ $yte_tag = <<<EOT
1170
+ <a class="colorbox_video" href="http://www.metacafe.com/fplayer/$file/$name.swf"><img width="$width" height="$height" src="$img_url" /></a></span>
1171
+ EOT;
1172
+ } else {
1173
+ $yte_tag = <<<EOT
1174
+ <embed flashVars="$flash_vars" src="http://www.metacafe.com/fplayer/$file/$name.swf" width="$width" height="$height" wmode="transparent" allowFullScreen="true" allowScriptAccess="always" name="Metacafe_6261286" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>
1175
+ EOT;
1176
+ }
1177
+
1178
+ return str_replace( '{video}', $yte_tag, html_entity_decode( $template ) );
1179
+ }
1180
+
1181
+ function tag_vimeo( $context, $file, $high = 'v', $side = 0 ) {
1182
+ $width = ( $context == 'excerpt' || $context == 'side' ) ?
1183
+ $this->options['widthside'] :
1184
+ ( $high ? $this->options['widthhq'] : $this->options['width'] );
1185
+
1186
+ $height = ( $context == 'excerpt' || $context == 'side' ) ?
1187
+ $this->options['heightside'] :
1188
+ ( $high ? $this->options['heighthq'] : $this->options['height'] );
1189
+
1190
+ if ( ! $width ) {
1191
+ $width = ! ( $high == 'v' ) ? 480 : 425 ;
1192
+ }
1193
+
1194
+ if ( ! $height ) {
1195
+ $height = ! ( $high == 'v' ) ? 360 : 344;
1196
+ }
1197
+
1198
+ $template = trim( $this->options['template'] ) == '' ? '{video}' : $this->options['template'];
1199
+ $excerpt = $this->options['excerpt'];
1200
+ $thumb = $this->options['thumb'];
1201
+ $colorbox = $this->options['colorbox'];
1202
+ $autoplay = $this->options['autoplay'];
1203
+ $autoplay_first = $this->options['autoplay_first'];
1204
+ $loop = $this->options['loop'];
1205
+
1206
+ $video_url = "http://player.vimeo.com/video/$file";
1207
+
1208
+ if ( $context == 'post' && $autoplay_first && ! $this->first ) {
1209
+ if ( is_single() ) {
1210
+ $video_url .= "?autoplay=1";
1211
+ } elseif ( $this->first_post_on_archive ) {
1212
+ $video_url .= "?autoplay=1";
1213
+ }
1214
+ if ( $loop ) {
1215
+ $video_url .= "&amp;loop=1";
1216
+ }
1217
+ $this->first = true;
1218
+ } else if ( ( $context == 'post' && $autoplay && ! $autoplay_first ) || ( $context == 'excerpt' && $autoplay ) ) {
1219
+ if ( is_single() ) {
1220
+ $video_url .= "?autoplay=1";
1221
+ } elseif ( $this->first_post_on_archive ) {
1222
+ $video_url .= "?autoplay=1";
1223
+ }
1224
+ if ( $loop ) {
1225
+ $video_url .= "&amp;loop=1";
1226
+ }
1227
+ } else {
1228
+ if ( $loop ) {
1229
+ $video_url .= "?loop=1";
1230
+ }
1231
+ }
1232
+
1233
+ if ( ( ( is_home() || is_front_page() || is_archive() ) && $context == 'post' && $thumb == 'on' ) || ( $context == 'thumb' ) || ( $context == 'excerpt' && $excerpt == 'thm' ) ) {
1234
+ $thumbs = unserialize(file_get_contents("http://vimeo.com/api/v2/video/$file.php"));
1235
+ $img_url = htmlspecialchars($thumbs[0]['thumbnail_large']);
1236
+ if ( $context == 'excerpt' && $excerpt == 'thm' ) {
1237
+ global $post;
1238
+ $post_url = get_permalink( $post->ID );
1239
+ $yte_tag = <<<EOT
1240
+ <a href="$post_url"><img src="$img_url" height="$height" width="$width" /></a>
1241
+ EOT;
1242
+ } else {
1243
+ $yte_tag = <<<EOT
1244
+ <img src="$img_url" height="$height" width="$width" />
1245
+ EOT;
1246
+ }
1247
+ }
1248
+ else if ( $context == 'post' && $colorbox == 'on' ) {
1249
+ $thumbs = unserialize( file_get_contents( "http://vimeo.com/api/v2/video/$file.php" ) );
1250
+ $img_url = htmlspecialchars( $thumbs[0]['thumbnail_large'] );
1251
+ $yte_tag = <<<EOT
1252
+ <a class="colorbox_video" href="$video_url"><img width="$width" height="$height" src="$img_url" /></a>
1253
+ EOT;
1254
+ } else {
1255
+ $yte_tag = <<<EOT
1256
+ <iframe src="$video_url" width="$width" height="$height" frameborder="0"></iframe>
1257
+ EOT;
1258
+ }
1259
+
1260
+ return str_replace( '{video}', $yte_tag, html_entity_decode( $template ) );
1261
+ }
1262
+
1263
+ function tag_liveleak( $context, $file, $high = 'v', $side = 0 ) {
1264
+ $width = ( $context == 'excerpt' || $context == 'side' ) ?
1265
+ $this->options['widthside'] :
1266
+ ( $high ? $this->options['widthhq'] : $this->options['width'] );
1267
+
1268
+ $height = ( $context == 'excerpt' || $context == 'side' ) ?
1269
+ $this->options['heightside'] :
1270
+ ( $high ? $this->options['heighthq'] : $this->options['height'] );
1271
+
1272
+ if ( ! $width ) {
1273
+ $width = ! ( $high == 'v' ) ? 480 : 425 ;
1274
+ }
1275
+
1276
+ if ( ! $height ) {
1277
+ $height = ! ( $high == 'v' ) ? 360 : 344;
1278
+ }
1279
+
1280
+ $template = trim($this->options['template']) == '' ? '{video}' : $this->options['template'];
1281
+ $thumb = $this->options['thumb'];
1282
+ $colorbox = $this->options['colorbox'];
1283
+ $excerpt = $this->options['excerpt'];
1284
+
1285
+ if ( ( ( is_home() || is_front_page() || is_archive() ) && $context == 'post' && $thumb == 'on' ) || ( $context == 'thumb' ) || ( $context == 'excerpt' && $excerpt == 'thm' ) ) {
1286
+ $img_url = htmlspecialchars( $this->plugin_url . '/img/default.jpg' );
1287
+ if ( $context == 'excerpt' && $excerpt == 'thm' ) {
1288
+ global $post;
1289
+ $post_url = get_permalink( $post->ID );
1290
+ $yte_tag = <<<EOT
1291
+ <a href="$post_url"><img src="$img_url" height="$height" width="$width" /></a>
1292
+ EOT;
1293
+ } else {
1294
+ $yte_tag = <<<EOT
1295
+ <img src="$img_url" height="$height" width="$width" />
1296
+ EOT;
1297
+ }
1298
+ } else if ( $context == 'post' && $colorbox == 'on' ) {
1299
+ $img_url = htmlspecialchars( $this->plugin_url . '/img/default.jpg' );
1300
+ $yte_tag = <<<EOT
1301
+ <a class="colorbox_video" href="http://www.liveleak.com/e/$file"><img width="$width" height="$height" src="$img_url" /></a></span>
1302
+ EOT;
1303
+ } else {
1304
+ $yte_tag = <<<EOT
1305
+ <object width="$width" height="$height"><param name="movie" value="http://www.liveleak.com/e/$file"></param><param name="wmode" value="transparent"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.liveleak.com/e/$file" type="application/x-shockwave-flash" wmode="transparent" allowscriptaccess="always" width="$width" height="$height"></embed></object>
1306
+ EOT;
1307
+ }
1308
+
1309
+ return str_replace( '{video}', $yte_tag, html_entity_decode( $template ) );
1310
+ }
1311
+
1312
+ function tag_facebook( $context, $file, $high = 'v', $side = 0 ) {
1313
+ $width = ( $context == 'excerpt' || $context == 'side' ) ?
1314
+ $this->options['widthside'] :
1315
+ ( $high ? $this->options['widthhq'] : $this->options['width'] );
1316
+
1317
+ $height = ( $context == 'excerpt' || $context == 'side' ) ?
1318
+ $this->options['heightside'] :
1319
+ ( $high ? $this->options['heighthq'] : $this->options['height'] );
1320
+
1321
+ if ( ! $width ) {
1322
+ $width = ! ( $high == 'v' ) ? 480 : 425 ;
1323
+ }
1324
+
1325
+ if ( ! $height ) {
1326
+ $height = ! ( $high == 'v' ) ? 360 : 344;
1327
+ }
1328
+
1329
+ $template = trim($this->options['template']) == '' ? '{video}' : $this->options['template'];
1330
+ $thumb = $this->options['thumb'];
1331
+ $colorbox = $this->options['colorbox'];
1332
+ $excerpt = $this->options['excerpt'];
1333
+
1334
+ if ( ( ( is_home() || is_front_page() || is_archive() ) && $context == 'post' && $thumb == 'on' ) || ( $context == 'thumb' ) || ( $context == 'excerpt' && $excerpt == 'thm' ) ) {
1335
+ $img_url = htmlspecialchars( $this->plugin_url . '/img/default.jpg' );
1336
+ if ( $context == 'excerpt' && $excerpt == 'thm' ) {
1337
+ global $post;
1338
+ $post_url = get_permalink( $post->ID );
1339
+ $yte_tag = <<<EOT
1340
+ <a href="$post_url"><img src="$img_url" height="$height" width="$width" /></a>
1341
+ EOT;
1342
+ } else {
1343
+ $yte_tag = <<<EOT
1344
+ <img src="$img_url" height="$height" width="$width" />
1345
+ EOT;
1346
+ }
1347
+ } else if ( $context == 'post' && $colorbox == 'on' ) {
1348
+ $img_url = htmlspecialchars( $this->plugin_url . '/img/default.jpg' );
1349
+ $yte_tag = <<<EOT
1350
+ <a class="colorbox_video" href="http://www.facebook.com/v/$file"><img width="$width" height="$height" src="$img_url" /></a></span>
1351
+ EOT;
1352
+ } else {
1353
+ $yte_tag = <<<EOT
1354
+ <object width="$width" height="$height"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" />
1355
+ <param name="movie" value="http://www.facebook.com/v/$file" /><embed src="http://www.facebook.com/v/$file" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="$width" height="$height"></embed></object>
1356
+ EOT;
1357
+ }
1358
+
1359
+ return str_replace( '{video}', $yte_tag, html_entity_decode( $template ) );
1360
+ }
1361
+
1362
+ function install() {
1363
+ add_action( 'widgets_init', array( $this, 'load_widgets' ) );
1364
+
1365
+ if ( get_option( $this->key ) ) {
1366
+ $this->options = $this->get_options();
1367
+ }
1368
+ }
1369
+
1370
+ // Handle our options
1371
+ function get_options() {
1372
+ $options = array(
1373
+ 'posts' => 'on',
1374
+ 'comments' => 'off',
1375
+ 'img' => 'off',
1376
+ 'width' => 425,
1377
+ 'height' => 344,
1378
+ 'widthhq' => 480,
1379
+ 'heighthq' => 295,
1380
+ 'widthside' => 200,
1381
+ 'heightside' => 167,
1382
+ 'rel' => 1,
1383
+ 'link' => 'on',
1384
+ 'valid' => 'off',
1385
+ 'search' => 'off',
1386
+ 'info' => 'on',
1387
+ 'ann' => 'on',
1388
+ 'template' => '{video}',
1389
+ 'autoplay' => 0,
1390
+ 'autoplay_first' => 0,
1391
+ 'privacy' => 0,
1392
+ 'wtext' => '',
1393
+ 'wtitle' => '',
1394
+ 'tag' => '',
1395
+ 'iframe' => 'on',
1396
+ 'http' => 'off',
1397
+ 'www' => 'off',
1398
+ 'loop' => 0,
1399
+ 'thumb' => 'off',
1400
+ 'colorbox' => 'off',
1401
+ 'colorbox_theme' => 1,
1402
+ 'excerpt' => 'not',
1403
+ 'logoless' => 'on',
1404
+ 'wiziapp' => 'off',
1405
+ 'theme' => 'dark'
1406
+ );
1407
+ $saved = get_option( $this->key );
1408
+
1409
+ if ( ! empty( $saved ) ) {
1410
+ foreach ( $saved as $key => $option ) {
1411
+ $options[$key] = $option;
1412
+ }
1413
+ }
1414
+
1415
+ if ( $saved != $options ) {
1416
+ update_option( $this->key, $options );
1417
+ }
1418
+
1419
+ return $options;
1420
+ }
1421
+
1422
+ function load_widgets() {
1423
+ register_widget( 'SmartYouTube_Widget' );
1424
+ }
1425
+
1426
+ /**
1427
+ * Gets plugin info from WordPress Codex repo
1428
+ * @return mixed
1429
+ */
1430
+ function get_info() {
1431
+ $checkfile = 'http://svn.wp-plugins.org/smart-youtube/trunk/smartyoutube.chk';
1432
+
1433
+ $status = array();
1434
+
1435
+ return $status; //???
1436
+
1437
+ $vcheck = wp_remote_fopen( $checkfile );
1438
+
1439
+ if ( $vcheck ) {
1440
+ $version = $this->local_version;
1441
+
1442
+ $status = explode( '@', $vcheck );
1443
+ return $status;
1444
+ }
1445
+ }
1446
+ }
1447
+
1448
+ class SmartYouTube_Widget extends WP_Widget {
1449
+ function SmartYouTube_Widget() {
1450
+ $widget_ops = array( 'classname' => 'smart-youtube', 'description' => 'A widget which dispalys some video from Youtube.' );
1451
+ $control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'smart-youtube' );
1452
+ $this->WP_Widget( 'smart-youtube', 'Smart Youtube', $widget_ops, $control_ops );
1453
+ }
1454
+
1455
+ function widget( $args, $instance ) {
1456
+ extract( $args );
1457
+ $text = smart_youtube_check( $instance['text'], 1 );
1458
+ $title = $instance['title'];
1459
+
1460
+ echo
1461
+ $before_widget,
1462
+ $before_title, $title, $after_title,
1463
+ $text,
1464
+ $after_widget;
1465
+ }
1466
+
1467
+ function update( $new_instance, $old_instance ) {
1468
+ $instance = $old_instance;
1469
+
1470
+ $instance['text'] = strip_tags( $new_instance['text'] );
1471
+ $instance['title'] = strip_tags( $new_instance['title'] );
1472
+ return $instance;
1473
+ }
1474
+
1475
+ function form( $instance ) {
1476
+ $defaults = array( 'title' => 'Smart Youtube Widget', 'text' => '' );
1477
+ $instance = wp_parse_args( ( array )$instance, $defaults );
1478
+ ?>
1479
+ <?php _e('Title:', 'smart-youtube'); ?><br /><input type="text" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" /><br />
1480
+ <?php _e('Insert HTML code below. In addition to normal text you may use httpv, httpvh and httpvhd links just like in your posts.'); ?><br />
1481
+ <textarea id="<?php echo $this->get_field_id( 'text' ); ?>" name="<?php echo $this->get_field_name( 'text' ); ?>" rows="10" cols="16" class="widefat"><?php echo $instance['text']; ?></textarea>
1482
+ <?php
1483
+ }
1484
+ }
1485
+
1486
+ function smart_youtube_check( $the_content, $side = 0 ) {
1487
+ global $smart_youtube_pro;
1488
+ return $smart_youtube_pro->check( $the_content, $side );
1489
+ }
1490
+
1491
+ function syt_show_thumb( $post_id ) {
1492
+ $p = get_post( $post_id );
1493
+ $content = $p->post_content;
1494
+
1495
+ preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?youtube\.com\/watch(\?v\=|\/v\/|#!v=)([a-zA-Z0-9\-\_]{11})([^<\s]*)/", $content, $matches['youtube.com'], PREG_SET_ORDER );
1496
+ preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?youtu\.be\/([a-zA-Z0-9\-\_]{11})/", $content, $matches['youtu.be'], PREG_SET_ORDER );
1497
+ preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?metacafe\.com\/watch\/([a-zA-Z0-9\-\_]{7})\/([^<^\/\s]*)([\/])?/", $content, $matches['metacafe.com'], PREG_SET_ORDER );
1498
+ preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?vimeo\.com\/([a-zA-Z0-9\-\_]{8})([\/])?/", $content, $matches['vimeo.com'], PREG_SET_ORDER );
1499
+ preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?liveleak\.com\/view(\?i\=)([a-zA-Z0-9\-\_]*)/", $content, $matches['liveleak.com'], PREG_SET_ORDER );
1500
+ preg_match_all( "/(http(v|vh|vhd)?:\/\/)?([a-zA-Z0-9\-\_]+\.|)?facebook\.com\/video\/video.php\?v\=([a-zA-Z0-9\-\_]*)/", $content, $matches['facebook.com'], PREG_SET_ORDER );
1501
+
1502
+ global $smart_youtube_pro;
1503
+
1504
+ if ( isset( $matches['youtube.com'][0] ) ) {
1505
+ if ( ( $matches['youtube.com'][0][1] == 'http://' && $smart_youtube_pro->options['http'] == 'on' ) || ( $matches['youtube.com'][0][1] == '' && $smart_youtube_pro->options['www'] == 'on' ) ) {
1506
+ $matches['youtube.com'][0][0] = str_replace( $matches['youtube.com'][0][0], $smart_youtube_pro->tag_youtube( 'excerpt', $matches['youtube.com'][0][5], 'v', $matches['youtube.com'][0][6] ), $matches['youtube.com'][0][0] );
1507
+ } else if ( $matches['youtube.com'][0][2] == 'v' || $matches['youtube.com'][0][2] == 'vh' || $matches['youtube.com'][0][2] == 'vhd' ) {
1508
+ $matches['youtube.com'][0][0] = str_replace( $matches['youtube.com'][0][0], $smart_youtube_pro->tag_youtube( 'excerpt', $matches['youtube.com'][0][5], $matches['youtube.com'][0][2], $matches['youtube.com'][0][6] ), $matches['youtube.com'][0][0] );
1509
+ }
1510
+ $result = $matches['youtube.com'][0][0];
1511
+ } else if ( isset( $matches['youtu.be'][0] ) ) {
1512
+ if ( ( $matches['youtu.be'][0][1] == 'http://' && $smart_youtube_pro->options['http'] == 'on' ) || ( $matches['youtu.be'][0][1] == '' && $smart_youtube_pro->options['www'] == 'on' ) ) {
1513
+ $matches['youtu.be'][0][0] = str_replace( $matches['youtu.be'][0][0], $smart_youtube_pro->tag_youtube( 'excerpt', $matches['youtu.be'][0][4], 'v' ), $matches['youtu.be'][0][0] );
1514
+ } else if ( $matches['youtu.be'][0][2] == 'v' || $matches['youtu.be'][0][2] == 'vh' || $matches['youtu.be'][0][2] == 'vhd' ) {
1515
+ $matches['youtu.be'][0][0] = str_replace( $matches['youtu.be'][0][0], $smart_youtube_pro->tag_youtube( 'excerpt', $matches['youtu.be'][0][4], $matches['youtu.be'][0][2]), $matches['youtu.be'][0][0] );
1516
+ }
1517
+ $result = $matches['youtu.be'][0][0];
1518
+ } else if ( isset( $matches['metacafe.com'][0] ) ) {
1519
+ if ( ( $matches['metacafe.com'][0][1] == 'http://' && $smart_youtube_pro->options['http'] == 'on' ) || ( $matches['metacafe.com'][0][1] == '' && $smart_youtube_pro->options['www'] == 'on' ) ) {
1520
+ $matches['metacafe.com'][0][0] = str_replace( $matches['metacafe.com'][0][0], $smart_youtube_pro->tag_metacafe( 'excerpt', $matches['metacafe.com'][0][4], 'v', $matches['metacafe.com'][0][5] ), $matches['metacafe.com'][0][0] );
1521
+ } else if ( $matches['metacafe.com'][0][2] == 'v' || $matches['metacafe.com'][0][2] == 'vh' || $matches['metacafe.com'][0][2] == 'vhd' ) {
1522
+ $matches['metacafe.com'][0][0] = str_replace( $matches['metacafe.com'][0][0], $smart_youtube_pro->tag_metacafe( 'excerpt', $matches['metacafe.com'][0][4], $matches['metacafe.com'][0][2], $matches['metacafe.com'][0][5] ), $matches['metacafe.com'][0][0] );
1523
+ }
1524
+ $result = $matches['metacafe.com'][0][0];
1525
+ } else if ( isset($matches['vimeo.com'][0] ) ) {
1526
+ if ( ( $matches['vimeo.com'][0][1] == 'http://' && $smart_youtube_pro->options['http'] == 'on' ) || ( $matches['vimeo.com'][0][1] == '' && $smart_youtube_pro->options['www'] == 'on' ) ) {
1527
+ $matches['vimeo.com'][0][0] = str_replace( $matches['vimeo.com'][0][0], $smart_youtube_pro->tag_vimeo( 'excerpt', $matches['vimeo.com'][0][4], 'v' ), $matches['vimeo.com'][0][0] );
1528
+ }
1529
+ else if ( $matches['vimeo.com'][0][2] == 'v' || $matches['vimeo.com'][0][2] == 'vh' || $matches['vimeo.com'][0][2] == 'vhd' ) {
1530
+ $matches['vimeo.com'][0][0] = str_replace( $matches['vimeo.com'][0][0], $smart_youtube_pro->tag_vimeo( 'excerpt', $matches['vimeo.com'][0][4], $matches['vimeo.com'][0][2] ), $matches['vimeo.com'][0][0] );
1531
+ }
1532
+ $result = $matches['vimeo.com'][0][0];
1533
+ } else if ( isset( $matches['liveleak.com'][0] ) ) {
1534
+ if ( ( $matches['liveleak.com'][0][1] == 'http://' && $smart_youtube_pro->options['http'] == 'on' ) || ( $matches['liveleak.com'][0][1] == '' && $smart_youtube_pro->options['www'] == 'on' ) ) {
1535
+ $matches['liveleak.com'][0][0] = str_replace( $matches['liveleak.com'][0][0], $smart_youtube_pro->tag_liveleak( 'excerpt', $matches['liveleak.com'][0][4], 'v' ), $matches['liveleak.com'][0][0] );
1536
+ } else if ( $matches['liveleak.com'][0][2] == 'v' || $matches['liveleak.com'][0][2] == 'vh' || $matches['liveleak.com'][0][2] == 'vhd' ) {
1537
+ $matches['liveleak.com'][0][0] = str_replace( $matches['liveleak.com'][0][0], $smart_youtube_pro->tag__liveleak( 'excerpt', $matches['liveleak.com'][0][4], $matches['liveleak.com'][0][2] ), $matches['liveleak.com'][0][0] );
1538
+ }
1539
+ $result = $matches['liveleak.com'][0][0];
1540
+ } else if ( isset( $matches['facebook.com'][0] ) ) {
1541
+ if ( ( $matches['facebook.com'][0][1] == 'http://' && $smart_youtube_pro->options['http'] == 'on' ) || ( $matches['facebook.com'][0][1] == '' && $smart_youtube_pro->options['www'] == 'on' ) ) {
1542
+ $matches['facebook.com'][0][0] = str_replace( $matches['facebook.com'][0][0], $smart_youtube_pro->tag_facebook( 'excerpt', $matches['facebook.com'][0][4], 'v' ), $matches['facebook.com'][0][0] );
1543
+ } else if ( $matches['facebook.com'][0][2] == 'v' || $matches['facebook.com'][0][2] == 'vh' || $matches['facebook.com'][0][2] == 'vhd' ) {
1544
+ $matches['facebook.com'][0][0] = str_replace( $matches['facebook.com'][0][0], $smart_youtube_pro->tag_facebook( 'excerpt', $matches['facebook.com'][0][4], $matches['facebook.com'][0][2] ), $matches['facebook.com'][0][0] );
1545
+ }
1546
+ $result = $matches['facebook.com'][0][0];
1547
+ } else {
1548
+ $width = $smart_youtube_pro->options['width'];
1549
+ $height = $smart_youtube_pro->options['height'];
1550
+
1551
+ $img_url = htmlspecialchars( $smart_youtube_pro->plugin_url . '/img/default.jpg' );
1552
+ $post_url = get_permalink( $post->ID );
1553
+ $yte_tag = <<<EOT
1554
+ <a href="$post_url">
1555
+ <img src="$img_url" height="$height" width="$width" />
1556
+ </a>
1557
+ EOT;
1558
+ $result = str_replace( '{video}', $yte_tag, html_entity_decode( $template ) );
1559
+ }
1560
+ if ( isset( $result ) ) {
1561
+ return $result;
1562
+ }
1563
+ }
1564
+ ?>