Video Sidebar Widgets - Version 4.0

Version Description

  • Fixed WordPress Video
  • Dropped Tangle Video (GodTube)
  • added admin settings page for disabling widgets

=

Download this release

Release Info

Developer denzel_chia
Plugin Icon 128x128 Video Sidebar Widgets
Version 4.0
Comparing to
See all releases

Code changes from version 3.0 to 4.0

class-randomvideosidebarwidget.php ADDED
@@ -0,0 +1,562 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Widget - Random Video Widget
4
+ *
5
+ */
6
+
7
+ class RandomVideoSidebarWidget extends WP_Widget {
8
+
9
+ function RandomVideoSidebarWidget() {
10
+ $widget_ops = array( 'classname' => 'randomvideosidebar', 'description' => __('A Random Video Widget. Randomly selects 1 of the 5 preset videos for display', 'randomvideosidebar') );
11
+ $control_ops = array( 'width' => 705, 'height' => 600, 'id_base' => 'randomvideosidebar' );
12
+ $this->WP_Widget( 'randomvideosidebar', __('Random Video Sidebar Widget', 'randomvideosidebar'), $widget_ops, $control_ops );
13
+ }
14
+
15
+
16
+ function widget( $args, $instance ) {
17
+ extract( $args );
18
+
19
+ $RV_title = apply_filters('widget_title', $instance['RV_title'] );
20
+ $RV_width = $instance['RV_width'];
21
+ $RV_height = $instance['RV_height'];
22
+ $RV_autoplay = $instance['RV_autoplay'];
23
+ $RV_id1 = $instance['RV_id1'];
24
+ $RV_source1 = $instance['RV_source1'];
25
+ $RV_cap1 = $instance['RV_cap1'];
26
+ $RV_id2 = $instance['RV_id2'];
27
+ $RV_source2 = $instance['RV_source2'];
28
+ $RV_cap2 = $instance['RV_cap2'];
29
+ $RV_id3 = $instance['RV_id3'];
30
+ $RV_source3 = $instance['RV_source3'];
31
+ $RV_cap3 = $instance['RV_cap3'];
32
+ $RV_id4 = $instance['RV_id4'];
33
+ $RV_source4 = $instance['RV_source4'];
34
+ $RV_cap4 = $instance['RV_cap4'];
35
+ $RV_id5 = $instance['RV_id5'];
36
+ $RV_source5 = $instance['RV_source5'];
37
+ $RV_cap5 = $instance['RV_cap5'];
38
+
39
+ echo $before_widget;
40
+
41
+ if ( $RV_title )
42
+ echo $before_title . $RV_title . $after_title;
43
+
44
+ //using rand() to select which video to show
45
+
46
+ $selection = rand(1,5);
47
+
48
+ switch($selection){
49
+
50
+ case 1:
51
+ $Embed_id = $RV_id1;
52
+ $Embed_source = $RV_source1;
53
+ $Embed_cap = $RV_cap1;
54
+ break;
55
+
56
+ case 2:
57
+ $Embed_id = $RV_id2;
58
+ $Embed_source = $RV_source2;
59
+ $Embed_cap = $RV_cap2;
60
+ break;
61
+
62
+ case 3:
63
+ $Embed_id = $RV_id3;
64
+ $Embed_source = $RV_source3;
65
+ $Embed_cap = $RV_cap3;
66
+ break;
67
+
68
+ case 4:
69
+ $Embed_id = $RV_id4;
70
+ $Embed_source = $RV_source4;
71
+ $Embed_cap = $RV_cap4;
72
+ break;
73
+
74
+ case 5:
75
+ $Embed_id = $RV_id5;
76
+ $Embed_source = $RV_source5;
77
+ $Embed_cap = $RV_cap5;
78
+ break;
79
+
80
+ }
81
+
82
+ //test for empty $Embed_id and empty $Embed_source. if empty,
83
+ //assign to same as first video id and source
84
+
85
+ If(empty($Embed_id)){
86
+ $Embed_id = $RV_id1;
87
+ $Embed_source = $RV_source1;
88
+ $Embed_cap = $RV_cap1;
89
+ }
90
+
91
+ $select_source = $Embed_source;
92
+
93
+ switch ($select_source) {
94
+
95
+ case null:
96
+ $rv_value = null;
97
+ $rv_flashvar = null;
98
+ $rv_flashvar2 = null;
99
+ $rv_cap = null;
100
+ break;
101
+
102
+ case YouTube:
103
+ $rv_value = "http://www.youtube.com/v/$Embed_id&autoplay=$RV_autoplay&loop=0&rel=0";
104
+ $rv_flashvar = null;
105
+ $rv_flashvar2 = null;
106
+ $rv_cap = $Embed_cap;
107
+ break;
108
+
109
+ case Vimeo:
110
+ $rv_value = "http://vimeo.com/moogaloop.swf?clip_id=$Embed_id&amp;server=vimeo.com&amp;loop=0&amp;fullscreen=1&amp;autoplay=$RV_autoplay";
111
+ $rv_flashvar = null;
112
+ $rv_flashvar2 = null;
113
+ $rv_cap = $Embed_cap;
114
+ break;
115
+
116
+ case MySpace:
117
+ $rv_value = "http://mediaservices.myspace.com/services/media/embed.aspx/m=$Embed_id,t=1,mt=video,ap=$RV_autoplay";
118
+ $rv_flashvar = null;
119
+ $rv_flashvar2 = null;
120
+ $rv_cap = $Embed_cap;
121
+ break;
122
+
123
+ case Veoh:
124
+ $rv_value = "http://www.veoh.com/static/swf/webplayer/WebPlayer.swf?version=AFrontend.5.4.2.20.1002&permalinkId=$Embed_id";
125
+ $rv_value.= "&player=videodetailsembedded&id=anonymous&videoAutoPlay=$RV_autoplay";
126
+ $rv_flashvar = null;
127
+ $rv_flashvar2 = null;
128
+ $rv_cap = $Embed_cap;
129
+ break;
130
+
131
+ case Blip:
132
+ $rv_value = "http://blip.tv/play/$Embed_id";
133
+ $rv_flashvar = null;
134
+ $rv_flashvar2 = null;
135
+ $rv_cap = $Embed_cap;
136
+ break;
137
+
138
+ case WordPress:
139
+ $rv_value = "http://v.wordpress.com/$Embed_id";
140
+ $rv_flashvar = null;
141
+ $rv_flashvar2 = null;
142
+ $rv_cap = $Embed_cap;
143
+ break;
144
+
145
+ case Viddler:
146
+ $rv_value = "http://www.viddler.com/player/$Embed_id";
147
+ if($RV_autoplay=='1'){
148
+ $rv_flashvar = "<param name=\"flashvars\" value=\"autoplay=t\" />\n";
149
+ $rv_flashvar2 = 'flashvars="autoplay=t" ';
150
+ }
151
+ $rv_cap = $Embed_cap;
152
+ break;
153
+
154
+ case DailyMotion:
155
+ $rv_value = "http://www.dailymotion.com/swf/$Embed_id&autoStart=$RV_autoplay&related=0";
156
+ $rv_flashvar = null;
157
+ $rv_flashvar2 = null;
158
+ $rv_cap = $Embed_cap;
159
+ break;
160
+
161
+
162
+ case Revver:
163
+ $rv_value = "http://flash.revver.com/player/1.0/player.swf?mediaId=$Embed_id&autoStart=$RV_autoplay";
164
+ $rv_flashvar = null;
165
+ $rv_flashvar2 = null;
166
+ $rv_cap = $Embed_cap;
167
+ break;
168
+
169
+ case Metacafe:
170
+ $rid = split('/',$Embed_id);
171
+ $rv_value = "http://www.metacafe.com/fplayer/$rid[0]/$rid[1].swf";
172
+ if($RV_autoplay=='1'){
173
+ $rv_flashvar = null;
174
+ $rv_flashvar2 = 'flashVars="playerVars=showStats=no|autoPlay=yes|"';
175
+ }
176
+ $rv_cap = $Embed_cap;
177
+ break;
178
+
179
+ case Tudou:
180
+ $rv_value = "$Embed_id";
181
+ $rv_flashvar = null;
182
+ $rv_flashvar2 = null;
183
+ $rv_cap = $Embed_cap;
184
+ break;
185
+
186
+ case Youku:
187
+ $rv_value = "$Embed_id";
188
+ $rv_flashvar = null;
189
+ $rv_flashvar2 = null;
190
+ $rv_cap = $Embed_cap;
191
+ break;
192
+
193
+ case cn6:
194
+ $rv_value = "$Embed_id";
195
+ $rv_flashvar = null;
196
+ $rv_flashvar2 = null;
197
+ $rv_cap = $Embed_cap;
198
+ break;
199
+
200
+ case Google:
201
+ $rv_value = "http://video.google.com/googleplayer.swf?docid=$Embed_id&hl=en&fs=true";
202
+ if($RV_autoplay=='1'){
203
+ $rv_flashvar = null;
204
+ $rv_flashvar2 = 'FlashVars="autoPlay=true&playerMode=embedded"';
205
+ }
206
+ $rv_cap = $Embed_cap;
207
+ break;
208
+
209
+ case Tangle:
210
+ $rv_value = "http://www.tangle.com/flash/swf/flvplayer.swf";
211
+ if($RV_autoplay=='1'){
212
+ $rv_flashvar = null;
213
+ $rv_flashvar2 = "FlashVars=\"viewkey=$Embed_id&autoplay=$RV_autoplay\"";
214
+ }else{
215
+ $rv_flashvar = null;
216
+ $rv_flashvar2 = "FlashVars=\"viewkey=$Embed_id\"";
217
+ }
218
+ $rv_cap = $Embed_cap;
219
+ break;
220
+
221
+
222
+
223
+ }
224
+
225
+
226
+
227
+ echo "\n<object width=\"$RV_width\" height=\"$RV_height\">\n";
228
+ echo $rv_flashvar;
229
+ echo "<param name=\"allowfullscreen\" value=\"true\" />\n";
230
+ echo "<param name=\"allowscriptaccess\" value=\"always\" />\n";
231
+ echo "<param name=\"movie\" value=\"$rv_value\" />\n";
232
+ echo "<param name=\"wmode\" value=\"transparent\">\n";
233
+ echo "<embed src=\"$rv_value\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" ";
234
+ echo "allowfullscreen=\"true\" allowscriptaccess=\"always\" ";
235
+ echo $rv_flashvar2;
236
+ echo "width=\"$RV_width\" height=\"$RV_height\">\n";
237
+ echo "</embed>\n";
238
+ echo "</object>\n\n";
239
+ echo "<p class=\"VideoCaption\">$rv_cap</p>";
240
+
241
+
242
+ echo $after_widget;
243
+ }
244
+
245
+
246
+ function update( $new_instance, $old_instance ) {
247
+ $instance = $old_instance;
248
+ $instance['RV_title'] = strip_tags( $new_instance['RV_title'] );
249
+ $instance['RV_width'] = strip_tags( $new_instance['RV_width'] );
250
+ $instance['RV_height'] = strip_tags( $new_instance['RV_height'] );
251
+ $instance['RV_autoplay'] = strip_tags( $new_instance['RV_autoplay'] );
252
+ $instance['RV_id1'] = strip_tags( $new_instance['RV_id1'] );
253
+ $instance['RV_source1'] = strip_tags( $new_instance['RV_source1'] );
254
+ $instance['RV_cap1'] = $new_instance['RV_cap1'];
255
+ $instance['RV_id2'] = strip_tags( $new_instance['RV_id2'] );
256
+ $instance['RV_source2'] = strip_tags( $new_instance['RV_source2'] );
257
+ $instance['RV_cap2'] = $new_instance['RV_cap2'];
258
+ $instance['RV_id3'] = strip_tags( $new_instance['RV_id3'] );
259
+ $instance['RV_source3'] = strip_tags( $new_instance['RV_source3'] );
260
+ $instance['RV_cap3'] = $new_instance['RV_cap3'];
261
+ $instance['RV_id4'] = strip_tags( $new_instance['RV_id4'] );
262
+ $instance['RV_source4'] = strip_tags( $new_instance['RV_source4'] );
263
+ $instance['RV_cap4'] = $new_instance['RV_cap4'];
264
+ $instance['RV_id5'] = strip_tags( $new_instance['RV_id5'] );
265
+ $instance['RV_source5'] = strip_tags( $new_instance['RV_source5'] );
266
+ $instance['RV_cap5'] = $new_instance['RV_cap5'];
267
+ return $instance;
268
+ }
269
+
270
+
271
+ function form($instance) {
272
+ $instance = wp_parse_args( (array) $instance, array( 'RV_title' => '', 'RV_width' => '', 'RV_height' => '', 'RV_autoplay' => '','RV_id1' => '','RV_source1' => '','RV_cap1' => '', 'RV_id2' => '','RV_source2' => '','RV_cap2' => '', 'RV_id3' => '','RV_source3' => '','RV_cap3' => '', 'RV_id4' => '','RV_source4' => '','RV_cap4' => '', 'RV_id5' => '','RV_source5' => '','RV_cap5' => '') );
273
+
274
+ $instance['RV_title'] = strip_tags( $instance['RV_title'] );
275
+ $instance['RV_width'] = strip_tags( $instance['RV_width'] );
276
+ $instance['RV_height'] = strip_tags( $instance['RV_height'] );
277
+ $instance['RV_autoplay'] = strip_tags( $instance['RV_autoplay'] );
278
+ $instance['RV_id1'] = strip_tags( $instance['RV_id1'] );
279
+ $instance['RV_source1'] = strip_tags( $instance['RV_source1'] );
280
+ $instance['RV_cap1'] = $instance['RV_cap1'];
281
+ $instance['RV_id2'] = strip_tags( $instance['RV_id2'] );
282
+ $instance['RV_source2'] = strip_tags( $instance['RV_source2'] );
283
+ $instance['RV_cap2'] = $instance['RV_cap2'];
284
+ $instance['RV_id3'] = strip_tags( $instance['RV_id3'] );
285
+ $instance['RV_source3'] = strip_tags( $instance['RV_source3'] );
286
+ $instance['RV_cap3'] = $instance['RV_cap3'];
287
+ $instance['RV_id4'] = strip_tags( $instance['RV_id4'] );
288
+ $instance['RV_source4'] = strip_tags( $instance['RV_source4'] );
289
+ $instance['RV_cap4'] = $instance['RV_cap4'];
290
+ $instance['RV_id5'] = strip_tags( $instance['RV_id5'] );
291
+ $instance['RV_source5'] = strip_tags( $instance['RV_source5'] );
292
+ $instance['RV_cap5'] = $instance['RV_cap5'];
293
+
294
+
295
+ ?>
296
+ <div style="width:220px;height:350px;float:left;margin:0px 15px 20px 5px">
297
+ <h2>General Settings</h2>
298
+ <!--Title -->
299
+ <p>
300
+ <label for="<?php echo $this->get_field_id('RV_title'); ?>">Widget Title:</label>
301
+ <input class="widefat" id="<?php echo $this->get_field_id('RV_title'); ?>" name="<?php echo $this->get_field_name('RV_title'); ?>" type="text" value="<?php echo $instance['RV_title']; ?>" />
302
+ </p>
303
+
304
+ <!--Width -->
305
+ <p>
306
+ <label for="<?php echo $this->get_field_id('RV_width'); ?>">Video Width: </label>
307
+ <input class="widefat" id="<?php echo $this->get_field_id('RV_width'); ?>" name="<?php echo $this->get_field_name('RV_width'); ?>" type="text" value="<?php echo $instance['RV_width']; ?>" />
308
+ </p>
309
+
310
+ <!--Height -->
311
+ <p>
312
+ <label for="<?php echo $this->get_field_id('RV_height'); ?>">Video Height: </label>
313
+ <input class="widefat" id="<?php echo $this->get_field_id('RV_height'); ?>" name="<?php echo $this->get_field_name('RV_height'); ?>" type="text" value="<?php echo $instance['RV_height']; ?>" />
314
+ </p>
315
+
316
+ <!--auto play -->
317
+ <p>
318
+ <label for="<?php echo $this->get_field_id( 'RV_autoplay' ); ?>">Auto Play:</label>
319
+ <select id="<?php echo $this->get_field_id( 'RV_autoplay' );?>" name="<?php echo $this->get_field_name( 'RV_autoplay' );?>" class="widefat" style="width:100%;">';
320
+ <option value='1' <?php if($instance['RV_autoplay'] == '1'){echo 'selected="selected"';}?>>Yes</option>
321
+ <option value='0' <?php if($instance['RV_autoplay'] == '0'){echo 'selected="selected"';}?>>No</option>
322
+ </select>
323
+ </p>
324
+ <p>Please fill up settings before clicking on save to display video.</p>
325
+ </div>
326
+
327
+ <div style="width:220px;height:350px;float:left;margin:0px 15px 20px 0px">
328
+ <!--first video setting -->
329
+ <h2>Video 1</h2>
330
+ <?php
331
+ //show video in Random Video Widget Admin
332
+ $autoplaysetting = '0';
333
+ $videoid = $instance['RV_id1'];
334
+ $videosource = $instance['RV_source1'];
335
+ $videowidth = null;
336
+ $videoheight = null;
337
+ //$admin = true // to show video in admin
338
+
339
+ VSWShowVideo($videosource,$videoid,$autoplaysetting,$videowidth,$videoheight,'true','false');
340
+ ?>
341
+ <p>
342
+ <label for="<?php echo $this->get_field_id( 'RV_source1' ); ?>">Select Video 1 Source:</label>
343
+ <select id="<?php echo $this->get_field_id( 'RV_source1' );?>" name="<?php echo $this->get_field_name( 'RV_source1' );?>" class="widefat" style="width:100%;">
344
+
345
+ <?php
346
+ $network = array('YouTube','Vimeo','MySpace','Veoh','Blip','WordPress','Viddler','DailyMotion','Revver','Metacafe','Tudou','Youku','cn6','Google');
347
+
348
+ foreach($network as $net){
349
+
350
+ echo "<option value='$net'";
351
+ if($instance['RV_source1'] == $net){
352
+ echo 'selected="selected"';
353
+ }
354
+ echo" >$net</option>";
355
+
356
+ }
357
+
358
+ ?>
359
+ </select>
360
+ </p>
361
+
362
+ <p>
363
+ <label for="<?php echo $this->get_field_id('RV_id1'); ?>">Video 1 ID: </label>
364
+ <input class="widefat" id="<?php echo $this->get_field_id('RV_id1'); ?>" name="<?php echo $this->get_field_name('RV_id1'); ?>" type="text" value="<?php echo $instance['RV_id1']; ?>" /></p>
365
+
366
+ <p>
367
+ <label for="<?php echo $this->get_field_id('RV_cap1'); ?>">Video Caption: </label>
368
+ <input class="widefat" id="<?php echo $this->get_field_id('RV_cap1'); ?>" name="<?php echo $this->get_field_name('RV_cap1'); ?>" type="text" value="<?php echo $instance['RV_cap1']; ?>" /></p>
369
+
370
+ </div>
371
+ <div style="width:220px;height:350px;float:left;margin:0px 15px 20px 0px">
372
+
373
+ <!--second video setting -->
374
+ <h2>Video 2</h2>
375
+ <?php
376
+ //show video in Random Video Widget Admin
377
+ $autoplaysetting = '0';
378
+ $videoid = $instance['RV_id2'];
379
+ $videosource = $instance['RV_source2'];
380
+ $videowidth = null;
381
+ $videoheight = null;
382
+ //$admin = true // to show video in admin
383
+
384
+ VSWShowVideo($videosource,$videoid,$autoplaysetting,$videowidth,$videoheight,'true','false');
385
+ ?>
386
+ <p>
387
+ <label for="<?php echo $this->get_field_id( 'RV_source2' ); ?>">Select Video 2 Source:</label>
388
+ <select id="<?php echo $this->get_field_id( 'RV_source2' );?>" name="<?php echo $this->get_field_name( 'RV_source2' );?>" class="widefat" style="width:100%;">
389
+
390
+ <?php
391
+ $network = array('YouTube','Vimeo','MySpace','Veoh','Blip','WordPress','Viddler','DailyMotion','Revver','Metacafe','Tudou','Youku','cn6','Google');
392
+
393
+ foreach($network as $net){
394
+
395
+ echo "<option value='$net'";
396
+ if($instance['RV_source2'] == $net){
397
+ echo 'selected="selected"';
398
+ }
399
+ echo" >$net</option>";
400
+
401
+ }
402
+
403
+ ?>
404
+
405
+
406
+ </select>
407
+ </p>
408
+
409
+ <p>
410
+ <label for="<?php echo $this->get_field_id('RV_id2'); ?>">Video 2 ID: </label>
411
+ <input class="widefat" id="<?php echo $this->get_field_id('RV_id2'); ?>" name="<?php echo $this->get_field_name('RV_id2'); ?>" type="text" value="<?php echo $instance['RV_id2']; ?>" /></p>
412
+
413
+ <p>
414
+ <label for="<?php echo $this->get_field_id('RV_cap2'); ?>">Video Caption: </label>
415
+ <input class="widefat" id="<?php echo $this->get_field_id('RV_cap2'); ?>" name="<?php echo $this->get_field_name('RV_cap2'); ?>" type="text" value="<?php echo $instance['RV_cap2']; ?>" /></p>
416
+
417
+ </div>
418
+ <div style="width:220px;height:350px;float:left;margin:0px 15px 20px 0px">
419
+
420
+ <!--third video setting -->
421
+ <h2>Video 3</h2>
422
+ <?php
423
+ //show video in Random Video Widget Admin
424
+ $autoplaysetting = '0';
425
+ $videoid = $instance['RV_id3'];
426
+ $videosource = $instance['RV_source3'];
427
+ $videowidth = null;
428
+ $videoheight = null;
429
+ //$admin = true // to show video in admin
430
+
431
+ VSWShowVideo($videosource,$videoid,$autoplaysetting,$videowidth,$videoheight,'true','false');
432
+ ?>
433
+ <p>
434
+ <label for="<?php echo $this->get_field_id( 'RV_source3' ); ?>">Select Video 3 Source:</label>
435
+ <select id="<?php echo $this->get_field_id( 'RV_source3' );?>" name="<?php echo $this->get_field_name( 'RV_source3' );?>" class="widefat" style="width:100%;">
436
+
437
+ <?php
438
+ $network = array('YouTube','Vimeo','MySpace','Veoh','Blip','WordPress','Viddler','DailyMotion','Revver','Metacafe','Tudou','Youku','cn6','Google');
439
+
440
+ foreach($network as $net){
441
+
442
+ echo "<option value='$net'";
443
+ if($instance['RV_source3'] == $net){
444
+ echo 'selected="selected"';
445
+ }
446
+ echo" >$net</option>";
447
+
448
+ }
449
+
450
+ ?>
451
+ </select>
452
+ </p>
453
+
454
+ <p>
455
+ <label for="<?php echo $this->get_field_id('RV_id3'); ?>">Video 3 ID: </label>
456
+ <input class="widefat" id="<?php echo $this->get_field_id('RV_id3'); ?>" name="<?php echo $this->get_field_name('RV_id3'); ?>" type="text" value="<?php echo $instance['RV_id3']; ?>" /></p>
457
+
458
+ <p>
459
+ <label for="<?php echo $this->get_field_id('RV_cap3'); ?>">Video Caption: </label>
460
+ <input class="widefat" id="<?php echo $this->get_field_id('RV_cap3'); ?>" name="<?php echo $this->get_field_name('RV_cap3'); ?>" type="text" value="<?php echo $instance['RV_cap3']; ?>" /></p>
461
+
462
+
463
+ </div>
464
+ <div style="width:220px;height:350px;float:left;margin:0px 15px 20px 5px">
465
+
466
+ <!--fourth video setting -->
467
+ <h2>Video 4</h2>
468
+ <?php
469
+ //show video in Random Video Widget Admin
470
+ $autoplaysetting = '0';
471
+ $videoid = $instance['RV_id4'];
472
+ $videosource = $instance['RV_source4'];
473
+ $videowidth = null;
474
+ $videoheight = null;
475
+ //$admin = true // to show video in admin
476
+
477
+ VSWShowVideo($videosource,$videoid,$autoplaysetting,$videowidth,$videoheight,'true','false');
478
+ ?>
479
+ <p>
480
+ <label for="<?php echo $this->get_field_id( 'RV_source4' ); ?>">Select Video 4 Source:</label>
481
+ <select id="<?php echo $this->get_field_id( 'RV_source4' );?>" name="<?php echo $this->get_field_name( 'RV_source4' );?>" class="widefat" style="width:100%;">
482
+
483
+ <?php
484
+ $network = array('YouTube','Vimeo','MySpace','Veoh','Blip','WordPress','Viddler','DailyMotion','Revver','Metacafe','Tudou','Youku','cn6','Google');
485
+
486
+ foreach($network as $net){
487
+
488
+ echo "<option value='$net'";
489
+ if($instance['RV_source4'] == $net){
490
+ echo 'selected="selected"';
491
+ }
492
+ echo" >$net</option>";
493
+
494
+ }
495
+
496
+ ?>
497
+ </select>
498
+ </p>
499
+
500
+ <p>
501
+ <label for="<?php echo $this->get_field_id('RV_id4'); ?>">Video 4 ID: </label>
502
+ <input class="widefat" id="<?php echo $this->get_field_id('RV_id4'); ?>" name="<?php echo $this->get_field_name('RV_id4'); ?>" type="text" value="<?php echo $instance['RV_id4']; ?>" /></p>
503
+
504
+ <p>
505
+ <label for="<?php echo $this->get_field_id('RV_cap4'); ?>">Video Caption: </label>
506
+ <input class="widefat" id="<?php echo $this->get_field_id('RV_cap4'); ?>" name="<?php echo $this->get_field_name('RV_cap4'); ?>" type="text" value="<?php echo $instance['RV_cap4']; ?>" /></p>
507
+
508
+ </div>
509
+ <div style="width:220px;height:350px;float:left;margin:0px 15px 20px 0px">
510
+
511
+ <!--fifth video setting -->
512
+ <h2>Video 5</h2>
513
+ <?php
514
+ //show video in Random Video Widget Admin
515
+ $autoplaysetting = '0';
516
+ $videoid = $instance['RV_id5'];
517
+ $videosource = $instance['RV_source5'];
518
+ $videowidth = null;
519
+ $videoheight = null;
520
+ //$admin = true // to show video in admin
521
+
522
+ VSWShowVideo($videosource,$videoid,$autoplaysetting,$videowidth,$videoheight,'true','false');
523
+ ?>
524
+ <p>
525
+ <label for="<?php echo $this->get_field_id( 'RV_source5' ); ?>">Select Video 5 Source:</label>
526
+ <select id="<?php echo $this->get_field_id( 'RV_source5' );?>" name="<?php echo $this->get_field_name( 'RV_source5' );?>" class="widefat" style="width:100%;">
527
+
528
+ <?php
529
+ $network = array('YouTube','Vimeo','MySpace','Veoh','Blip','WordPress','Viddler','DailyMotion','Revver','Metacafe','Tudou','Youku','cn6','Google');
530
+
531
+ foreach($network as $net){
532
+
533
+ echo "<option value='$net'";
534
+ if($instance['RV_source5'] == $net){
535
+ echo 'selected="selected"';
536
+ }
537
+ echo" >$net</option>";
538
+
539
+ }
540
+
541
+ ?>
542
+ </select>
543
+ </p>
544
+
545
+ <p>
546
+ <label for="<?php echo $this->get_field_id('RV_id5'); ?>">Video 5 ID: </label>
547
+ <input class="widefat" id="<?php echo $this->get_field_id('RV_id5'); ?>" name="<?php echo $this->get_field_name('RV_id5'); ?>" type="text" value="<?php echo $instance['RV_id5']; ?>" /></p>
548
+
549
+ <p>
550
+ <label for="<?php echo $this->get_field_id('RV_cap5'); ?>">Video Caption: </label>
551
+ <input class="widefat" id="<?php echo $this->get_field_id('RV_cap5'); ?>" name="<?php echo $this->get_field_name('RV_cap5'); ?>" type="text" value="<?php echo $instance['RV_cap5']; ?>" /></p>
552
+
553
+ </div>
554
+ <p style="clear:both"></p>
555
+
556
+
557
+ <?php
558
+
559
+ }
560
+
561
+ }
562
+ ?>
class-videosidebarwidget.php ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Widget - Video Sidebar Widget
4
+ */
5
+
6
+ //Video Sidebar Widget Class to extend WP_Widget class
7
+ class VideoSidebarWidget extends WP_Widget {
8
+
9
+ //function to set up widget in admin
10
+ function VideoSidebarWidget() {
11
+
12
+ $widget_ops = array( 'classname' => 'videosidebar',
13
+ 'description' => __('A Video Widget to display video in sidebar from various video sharing networks', 'videosidebar') );
14
+
15
+ $control_ops = array( 'width' => 200, 'height' => 350, 'id_base' => 'videosidebar' );
16
+ $this->WP_Widget( 'videosidebar', __('Video Sidebar Widget', 'videosidebar'), $widget_ops, $control_ops );
17
+
18
+ }
19
+
20
+
21
+ //function to echo out widget on sidebar
22
+ function widget( $args, $instance ) {
23
+ extract( $args );
24
+
25
+ $title2 = apply_filters('widget_title2', $instance['title2'] );
26
+ $cap2 = $instance['v_cap2'];
27
+
28
+ echo $before_widget;
29
+
30
+ // if user written title echo out
31
+ if ( $title2 ){
32
+ echo $before_title . $title2 . $after_title;
33
+ }
34
+
35
+ //get settings from Widget Admin Form to assign to function VSWShowVideo
36
+ $autoplaysetting = $instance['v_autoplay2'];
37
+ $videoid = $instance['v_id2'];
38
+ $videosource = $instance['v_source'];
39
+ $videowidth = $instance['v_width2'];
40
+ $videoheight = $instance['v_height2'];
41
+
42
+ //function to show video in blog sidebar, please look for it below
43
+ VSWShowVideo($videosource,$videoid,$autoplaysetting,$videowidth,$videoheight,'false','false');
44
+
45
+ if($cap2){
46
+ echo "<p class=\"VideoCaption\">$cap2</p>";
47
+ }
48
+
49
+ echo $after_widget;
50
+
51
+ }//end of function widget
52
+
53
+
54
+
55
+ //function to update widget setting
56
+ function update( $new_instance, $old_instance ) {
57
+
58
+ $instance = $old_instance;
59
+ $instance['title2'] = strip_tags( $new_instance['title2'] );
60
+ $instance['v_width2'] = strip_tags( $new_instance['v_width2'] );
61
+ $instance['v_height2'] = strip_tags( $new_instance['v_height2'] );
62
+ $instance['v_autoplay2'] = strip_tags( $new_instance['v_autoplay2'] );
63
+ $instance['v_id2'] = strip_tags( $new_instance['v_id2'] );
64
+ $instance['v_source'] = strip_tags( $new_instance['v_source'] );
65
+ $instance['v_cap2'] = $new_instance['v_cap2'];
66
+ return $instance;
67
+
68
+ }//end of function update
69
+
70
+
71
+ //function to create Widget Admin form
72
+ function form($instance) {
73
+
74
+ $instance = wp_parse_args( (array) $instance, array( 'title2' => '', 'v_width2' => '', 'v_height2' => '',
75
+ 'v_autoplay2' => '','v_id2' => '','v_source' => '','v_cap2' => '') );
76
+
77
+ $instance['title2'] = strip_tags( $instance['title2'] );
78
+ $instance['v_width2'] = strip_tags( $instance['v_width2'] );
79
+ $instance['v_height2'] = strip_tags( $instance['v_height2'] );
80
+ $instance['v_autoplay2'] = strip_tags( $instance['v_autoplay2'] );
81
+ $instance['v_id2'] = strip_tags( $instance['v_id2'] );
82
+ $instance['v_source'] = strip_tags( $instance['v_source'] );
83
+ $instance['v_cap2'] = $instance['v_cap2'];
84
+
85
+ //function to show video in widget admin form fixed width and height, please look for it below
86
+ $autoplaysetting = '0';
87
+ $videoid = $instance['v_id2'];
88
+ $videosource = $instance['v_source'];
89
+ $videowidth = null;
90
+ $videoheight = null;
91
+ //$admin = true // to show video in admin
92
+
93
+ VSWShowVideo($videosource,$videoid,$autoplaysetting,$videowidth,$videoheight,'true','false');
94
+
95
+ ?>
96
+
97
+
98
+ <p>
99
+ <label for="<?php echo $this->get_field_id('title2'); ?>">Widget Title:</label>
100
+ <input class="widefat" id="<?php echo $this->get_field_id('title2'); ?>" name="<?php echo $this->get_field_name('title2'); ?>"
101
+ type="text" value="<?php echo $instance['title2']; ?>" />
102
+ </p>
103
+
104
+ <p>
105
+ <label for="<?php echo $this->get_field_id( 'v_source' ); ?>">Select Video Source:</label>
106
+ <select id="<?php echo $this->get_field_id( 'v_source' );?>" name="<?php echo $this->get_field_name( 'v_source' );?>" class="widefat" style="width:100%;">
107
+
108
+ <?php
109
+ $network = array('YouTube','Vimeo','MySpace','Veoh','Blip','WordPress','Viddler','DailyMotion','Revver','Metacafe','Tudou','Youku','cn6','Google');
110
+
111
+ foreach($network as $net){
112
+
113
+ echo "<option value='$net'";
114
+ if($instance['v_source'] == $net){
115
+ echo 'selected="selected"';
116
+ }
117
+ echo" >$net</option>";
118
+
119
+ }
120
+
121
+ ?>
122
+
123
+
124
+ </select>
125
+ </p>
126
+
127
+ <p>
128
+ <label for="<?php echo $this->get_field_id('v_id2'); ?>">Video ID: </label>
129
+ <input class="widefat" id="<?php echo $this->get_field_id('v_id2'); ?>"
130
+ name="<?php echo $this->get_field_name('v_id2'); ?>" type="text" value="<?php echo $instance['v_id2']; ?>" /></p>
131
+
132
+ <p>
133
+ <label for="<?php echo $this->get_field_id('v_width2'); ?>">Video Width: </label>
134
+ <input class="widefat" id="<?php echo $this->get_field_id('v_width2'); ?>"
135
+ name="<?php echo $this->get_field_name('v_width2'); ?>" type="text" value="<?php echo $instance['v_width2']; ?>" />
136
+ </p>
137
+
138
+ <p>
139
+ <label for="<?php echo $this->get_field_id('v_height2'); ?>">Video Height: </label>
140
+ <input class="widefat" id="<?php echo $this->get_field_id('v_height2'); ?>"
141
+ name="<?php echo $this->get_field_name('v_height2'); ?>" type="text" value="<?php echo $instance['v_height2']; ?>" />
142
+ </p>
143
+
144
+ <p>
145
+ <label for="<?php echo $this->get_field_id('v_cap2'); ?>">Video Caption: </label>
146
+ <input class="widefat" id="<?php echo $this->get_field_id('v_cap2'); ?>"
147
+ name="<?php echo $this->get_field_name('v_cap2'); ?>" type="text" value="<?php echo $instance['v_cap2']; ?>" />
148
+ </p>
149
+
150
+
151
+ <p>
152
+
153
+ <?php
154
+
155
+ // check whether autoplay feature supported by video network
156
+ $source = $instance['v_source'];
157
+ $msg = "<p>Sorry, auto play option not supported by ".$source."</p>";
158
+ switch ($source) {
159
+
160
+ case WordPress:
161
+ echo $msg;
162
+ break;
163
+
164
+ case Tudou:
165
+ echo $msg;
166
+ break;
167
+
168
+ case Youku:
169
+ echo $msg;
170
+ break;
171
+
172
+ case Blip:
173
+ echo "<p>Sorry, auto play option removed as it is causing error in Internet Explorer</p>";
174
+ break;
175
+
176
+ case cn6:
177
+ echo "<p>Sorry, auto play option not supported by 6.cn</p>";
178
+ break;
179
+ }
180
+
181
+ ?>
182
+
183
+ <label for="<?php echo $this->get_field_id( 'v_autoplay2' ); ?>">Auto Play:</label>
184
+ <select id="<?php echo $this->get_field_id( 'v_autoplay2' );?>"
185
+ name="<?php echo $this->get_field_name( 'v_autoplay2' );?>" class="widefat" style="width:100%;">';
186
+ <option value='1' <?php if($instance['v_autoplay2'] == '1'){echo 'selected="selected"';}?>>Yes</option>
187
+ <option value='0' <?php if($instance['v_autoplay2'] == '0'){echo 'selected="selected"';}?>>No</option>
188
+ </select>
189
+ </p>
190
+
191
+ <?php
192
+
193
+ }//end of function form($instance)
194
+
195
+ }//end of Video Sidebar Widget Class
196
+ ?>
helper-functions.php ADDED
@@ -0,0 +1,315 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Helper Functions.
4
+ *
5
+ **/
6
+
7
+ //Main Video Function
8
+ function VSWShowVideo($videosource,$videoid,$autoplaysetting,$videowidth,$videoheight,$admin,$shortcode){
9
+
10
+ //admin = true to show in widget admin
11
+ //admin = false to show in blog sidebar
12
+
13
+ $v_autoplay2 = $autoplaysetting;
14
+ $v_id2 = $videoid;
15
+ $v_source = $videosource;
16
+ $v_width2 = $videowidth;
17
+ $v_height2 = $videoheight;
18
+
19
+ $source = $v_source;
20
+
21
+ //test for source and assign codes accordingly
22
+ switch ($source) {
23
+
24
+ case null:
25
+ $value = null;
26
+ $flashvar = null;
27
+ $flashvar2 = null;
28
+ break;
29
+
30
+ case YouTube:
31
+ $value = "http://www.youtube.com/v/$v_id2&autoplay=$v_autoplay2&loop=0&rel=0";
32
+ $flashvar = null;
33
+ $flashvar2 = null;
34
+ break;
35
+
36
+ case Vimeo:
37
+ $value = "http://vimeo.com/moogaloop.swf?clip_id=$v_id2&amp;server=vimeo.com&amp;loop=0&amp;fullscreen=1&amp;autoplay=$v_autoplay2";
38
+ $flashvar = null;
39
+ $flashvar2 = null;
40
+ break;
41
+
42
+ case MySpace:
43
+ $value = "http://mediaservices.myspace.com/services/media/embed.aspx/m=$v_id2,t=1,mt=video,ap=$v_autoplay2";
44
+ $flashvar = null;
45
+ $flashvar2 = null;
46
+ break;
47
+
48
+ case Veoh:
49
+ $value = "http://www.veoh.com/static/swf/webplayer/WebPlayer.swf?version=AFrontend.5.4.2.20.1002&";
50
+ $value.= "permalinkId=$v_id2&player=videodetailsembedded&id=anonymous&videoAutoPlay=$v_autoplay2";
51
+ $flashvar = null;
52
+ $flashvar2 = null;
53
+ break;
54
+
55
+ case Blip:
56
+ $value = "http://blip.tv/play/$v_id2";
57
+ $flashvar = null;
58
+ $flashvar2 = null;
59
+ break;
60
+
61
+ case WordPress:
62
+ $value = "http://s0.videopress.com/player.swf?v=1.02";
63
+ $flashvar = "<param name='flashvars' value='$v_id2'>";
64
+ $flashvar2 = 'flashvars="guid='.$v_id2.'"';
65
+ break;
66
+
67
+ case Viddler:
68
+ $value = "http://www.viddler.com/player/$v_id2";
69
+ if($v_autoplay2=='1'){
70
+ $flashvar = "<param name=\"flashvars\" value=\"autoplay=t\" />\n";
71
+ $flashvar2 = 'flashvars="autoplay=t" ';
72
+ }
73
+ break;
74
+
75
+ case DailyMotion:
76
+ $value = "http://www.dailymotion.com/swf/$v_id2&autoStart=$v_autoplay2&related=0";
77
+ $flashvar = null;
78
+ $flashvar2 = null;
79
+ break;
80
+
81
+
82
+ case Revver:
83
+ $value = "http://flash.revver.com/player/1.0/player.swf?mediaId=$v_id2&autoStart=$v_autoplay2";
84
+ $flashvar = null;
85
+ $flashvar2 = null;
86
+ break;
87
+
88
+ case Metacafe:
89
+ $id = split('/',$v_id2);
90
+ $value = "http://www.metacafe.com/fplayer/$id[0]/$id[1].swf";
91
+ if($v_autoplay2=='1'){
92
+ $flashvar = null;
93
+ $flashvar2 = 'flashVars="playerVars=showStats=no|autoPlay=yes|"';
94
+ }
95
+ break;
96
+
97
+ case Tudou:
98
+ $value = "$v_id2";
99
+ $flashvar = null;
100
+ $flashvar2 = null;
101
+ break;
102
+
103
+ case Youku:
104
+ $value = "$v_id2";
105
+ $flashvar = null;
106
+ $flashvar2 = null;
107
+ break;
108
+
109
+ case cn6:
110
+ $value = "$v_id2";
111
+ $flashvar = null;
112
+ $flashvar2 = null;
113
+ break;
114
+
115
+ case Google:
116
+ $value = "http://video.google.com/googleplayer.swf?docid=$v_id2&hl=en&fs=true";
117
+ if($v_autoplay2=='1'){
118
+ $flashvar = null;
119
+ $flashvar2 = 'FlashVars="autoPlay=true&playerMode=embedded"';
120
+ }
121
+ break;
122
+
123
+ case Tangle:
124
+ $value = "http://www.tangle.com/flash/swf/flvplayer.swf";
125
+ if($v_autoplay2=='1'){
126
+ $flashvar = null;
127
+ $flashvar2 = "FlashVars=\"viewkey=$v_id2&autoplay=$v_autoplay2\"";
128
+ }else{
129
+ $flashvar = null;
130
+ $flashvar2 = "FlashVars=\"viewkey=$v_id2\"";
131
+ }
132
+ break;
133
+
134
+ }
135
+
136
+ if($shortcode=="true"){
137
+ //added in version 2.3
138
+ //return instead of echo video on blog using shortcode
139
+ $vsw_code = "\n<object width=\"$v_width2\" height=\"$v_height2\">\n";
140
+ $vsw_code .= $flashvar;
141
+ $vsw_code .= "<param name=\"allowfullscreen\" value=\"true\" />\n";
142
+ $vsw_code .= "<param name=\"allowscriptaccess\" value=\"always\" />\n";
143
+ $vsw_code .= "<param name=\"movie\" value=\"$value\" />\n";
144
+ $vsw_code .= "<param name=\"wmode\" value=\"transparent\">\n";
145
+ $vsw_code .= "<embed src=\"$value\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" ";
146
+ $vsw_code .= "allowfullscreen=\"true\" allowscriptaccess=\"always\" ";
147
+ $vsw_code .= $flashvar2;
148
+ $vsw_code .= "width=\"$v_width2\" height=\"$v_height2\">\n";
149
+ $vsw_code .= "</embed>\n";
150
+ $vsw_code .= "</object>\n\n";
151
+ return $vsw_code;
152
+ }
153
+ elseif($admin=="true"){
154
+ // echo video in admin
155
+ echo "\n<object width=\"212\" height=\"172\">\n";
156
+ echo $flashvar;
157
+ echo "<param name=\"allowfullscreen\" value=\"true\" />\n";
158
+ echo "<param name=\"allowscriptaccess\" value=\"always\" />\n";
159
+ echo "<param name=\"movie\" value=\"$value\" />\n";
160
+ echo "<param name=\"wmode\" value=\"transparent\">\n";
161
+ echo "<embed src=\"$value\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" ";
162
+ echo "allowfullscreen=\"true\" allowscriptaccess=\"always\" ";
163
+ echo $flashvar2;
164
+ echo "width=\"212\" height=\"172\">\n";
165
+ echo "</embed>\n";
166
+ echo "</object>\n\n";
167
+
168
+ }else{
169
+
170
+ // echo video on blog
171
+ echo "\n<object width=\"$v_width2\" height=\"$v_height2\">\n";
172
+ echo $flashvar;
173
+ echo "<param name=\"allowfullscreen\" value=\"true\" />\n";
174
+ echo "<param name=\"allowscriptaccess\" value=\"always\" />\n";
175
+ echo "<param name=\"movie\" value=\"$value\" />\n";
176
+ echo "<param name=\"wmode\" value=\"transparent\">\n";
177
+ echo "<embed src=\"$value\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" ";
178
+ echo "allowfullscreen=\"true\" allowscriptaccess=\"always\" ";
179
+ echo $flashvar2;
180
+ echo "width=\"$v_width2\" height=\"$v_height2\">\n";
181
+ echo "</embed>\n";
182
+ echo "</object>\n\n";
183
+ }
184
+
185
+
186
+ }//end of function VSWShowVideo
187
+
188
+ /**
189
+ * Added in Version 2.3
190
+ * Shortcode to echo out video
191
+ * Usage [vsw id="123456" source="vimeo" width="400" height="300" autoplay="no"]
192
+ **/
193
+
194
+ function vsw_show_video($atts, $content = null) {
195
+ extract(shortcode_atts(array(
196
+ "id" => ' ',
197
+ "source" => ' ',
198
+ "width" => ' ',
199
+ "height" => ' ',
200
+ "autoplay" => ' ',
201
+ ), $atts));
202
+
203
+ return vsw_show_video_class($id,$source,$width,$height,$autoplay);
204
+ }
205
+
206
+ add_shortcode("vsw", "vsw_show_video");
207
+
208
+ //function to be used in shortcode or directly in theme
209
+ //uses the_widget WordPress Function found in widgets.php
210
+ function vsw_show_video_class($id,$source,$width,$height,$autoplay){
211
+
212
+ $vsw_id = $id;
213
+ $vsw_width = $width;
214
+ $vsw_height = $height;
215
+
216
+ //convert string of source to lowercase
217
+ $source = strtolower($source);
218
+
219
+ //should have used all lowercase in previous functions
220
+ //now have to switch it.
221
+ switch ($source) {
222
+
223
+ case null:
224
+ $vsw_source = null;
225
+ break;
226
+
227
+ case youtube:
228
+ $vsw_source = YouTube;
229
+ break;
230
+
231
+ case vimeo:
232
+ $vsw_source = Vimeo;
233
+ break;
234
+
235
+ case myspace:
236
+ $vsw_source = MySpace;
237
+ break;
238
+
239
+ case veoh:
240
+ $vsw_source = Veoh;
241
+ break;
242
+
243
+ case bliptv:
244
+ $vsw_source = Blip;
245
+ break;
246
+
247
+ case wordpress:
248
+ $vsw_source = WordPress;
249
+ break;
250
+
251
+ case viddler:
252
+ $vsw_source = Viddler;
253
+ break;
254
+
255
+ case dailymotion:
256
+ $vsw_source = DailyMotion;
257
+ break;
258
+
259
+
260
+ case revver:
261
+ $vsw_source = Revver;
262
+ break;
263
+
264
+ case metacafe:
265
+ $vsw_source = Metacafe;
266
+ break;
267
+
268
+ case tudou:
269
+ $vsw_source = Tudou;
270
+ break;
271
+
272
+ case youku:
273
+ $vsw_source = Youku;
274
+ break;
275
+
276
+ case cn6:
277
+ $vsw_source = cn6;
278
+ break;
279
+
280
+ case google:
281
+ $vsw_source = Google;
282
+ break;
283
+
284
+ case tangle:
285
+ $vsw_source = Tangle;
286
+ break;
287
+
288
+ }
289
+
290
+ //string to lowercase
291
+ $autoplay = strtolower($autoplay);
292
+
293
+ //switch autoplay yes or no to 1 or 0
294
+ switch ($autoplay) {
295
+
296
+ case null:
297
+ $vsw_autoplay = 0;
298
+ break;
299
+
300
+ case no:
301
+ $vsw_autoplay = 0;
302
+ break;
303
+
304
+ case yes:
305
+ $vsw_autoplay = 1;
306
+ break;
307
+
308
+ }
309
+
310
+
311
+ $vsw_code = VSWShowVideo($vsw_source,$vsw_id,$vsw_autoplay,$vsw_width,$vsw_height,'false','true');
312
+
313
+ return $vsw_code;
314
+ }
315
+ ?>
readme.txt CHANGED
@@ -4,13 +4,13 @@ Donate link: http://denzeldesigns.com/wordpress-plugins/video-sidebar-widgets/
4
  Author link: http://denzeldesigns.com
5
  Tags:video, widget, widgets, sidebar, videos, video sidebar widget, video widget, embed video, video embed, video in sidebar, youtube, vimeo, veoh, myspace video, revver, blip tv, tudou, youku, 6.cn, google videos, tangle
6
  Requires at least:2.8.1
7
- Tested up to: 3.0.5
8
- Stable tag:3.0
9
 
10
  == Description ==
11
 
12
- A Video Widget written in latest Widgets API. It enables the user to embed FlashVideo from various video sharing networks into the widgetised sidebar of a WordPress powered blog. Currently supporting video embed from 15 video sharing networks. Including, Youtube, Vimeo, Veoh, Blip.tv etc..
13
- Now including Random Video Sidebar Widget to randomly display 1 out of 5 preset video.
14
 
15
  == Changelog ==
16
 
@@ -45,6 +45,11 @@ Now including Random Video Sidebar Widget to randomly display 1 out of 5 preset
45
  *added video quicktag at post editor to insert video shortcode into post or page.
46
  *Shortcode to allow posting of video on post or page, using video function already available in plugin.
47
 
 
 
 
 
 
48
 
49
  == Installation ==
50
 
@@ -69,12 +74,12 @@ User can use the video Quicktag at Tinymce editor to insert video shortcode.
69
 
70
  == How to use Video Sidebar Widget ? ==
71
 
72
- Please visit plugin site for details.
73
 
74
 
75
  == How to use Random Video Sidebar Widget ? ==
76
 
77
- Please visit plugin site for details.
78
 
79
 
80
  == Frequently Asked Questions ==
4
  Author link: http://denzeldesigns.com
5
  Tags:video, widget, widgets, sidebar, videos, video sidebar widget, video widget, embed video, video embed, video in sidebar, youtube, vimeo, veoh, myspace video, revver, blip tv, tudou, youku, 6.cn, google videos, tangle
6
  Requires at least:2.8.1
7
+ Tested up to: 3.1.1
8
+ Stable tag:4.0
9
 
10
  == Description ==
11
 
12
+ A collection of sidebar widgets for displaying Flash Videos from 14 video sharing networks.
13
+ Video networks includes Youtube, Vimeo, BlipTV, Google, etc. This plugin consist of 2 widgets and 1 TinyMCE editor button.
14
 
15
  == Changelog ==
16
 
45
  *added video quicktag at post editor to insert video shortcode into post or page.
46
  *Shortcode to allow posting of video on post or page, using video function already available in plugin.
47
 
48
+ = 4.0 =
49
+
50
+ * Fixed WordPress Video
51
+ * Dropped Tangle Video (GodTube)
52
+ * added admin settings page for disabling widgets
53
 
54
  == Installation ==
55
 
74
 
75
  == How to use Video Sidebar Widget ? ==
76
 
77
+ Please visit plugin site for details. http://denzeldesigns.com
78
 
79
 
80
  == How to use Random Video Sidebar Widget ? ==
81
 
82
+ Please visit plugin site for details. http://denzeldesigns.com
83
 
84
 
85
  == Frequently Asked Questions ==
source_image/rvw.png ADDED
Binary file
source_image/tinybutton.png ADDED
Binary file
source_image/vsw.png ADDED
Binary file
video-sidebar-widgets.php CHANGED
@@ -2,1131 +2,38 @@
2
  /*
3
  Plugin Name: Video Sidebar Widgets
4
  Plugin URI: http://denzeldesigns.com/wordpress-plugins/video-sidebar-widgets/
5
- Version: 3.0
6
  Description: Video Sidebar Widgets to display videos such as Vimeo, YouTube, MySpace Videos etc. Now with added shortcode and quicktag to embed video in post and page content.
7
  Author: Denzel Chia
8
  Author URI: http://denzeldesigns.com/
9
  */
10
 
 
 
11
 
12
- //action to initiate widgets
13
- add_action('widgets_init', 'load_video_sidebar_widgets');
14
-
15
-
16
- //function to register Video Sidebar Widget and Random Video Sidebar Widget
17
- function load_video_sidebar_widgets() {
18
- register_widget('VideoSidebarWidget');
19
- register_widget('RandomVideoSidebarWidget');
20
- }
21
-
22
-
23
- //Video Sidebar Widget Class to extend WP_Widget class
24
- class VideoSidebarWidget extends WP_Widget {
25
-
26
- //function to set up widget in admin
27
- function VideoSidebarWidget() {
28
-
29
- $widget_ops = array( 'classname' => 'videosidebar',
30
- 'description' => __('A Video Widget to display video in sidebar from various video sharing networks', 'videosidebar') );
31
-
32
- $control_ops = array( 'width' => 200, 'height' => 350, 'id_base' => 'videosidebar' );
33
- $this->WP_Widget( 'videosidebar', __('Video Sidebar Widget', 'videosidebar'), $widget_ops, $control_ops );
34
-
35
- }
36
-
37
-
38
- //function to echo out widget on sidebar
39
- function widget( $args, $instance ) {
40
- extract( $args );
41
-
42
- $title2 = apply_filters('widget_title2', $instance['title2'] );
43
- $cap2 = $instance['v_cap2'];
44
-
45
- echo $before_widget;
46
-
47
- // if user written title echo out
48
- if ( $title2 ){
49
- echo $before_title . $title2 . $after_title;
50
- }
51
-
52
- //get settings from Widget Admin Form to assign to function VSWShowVideo
53
- $autoplaysetting = $instance['v_autoplay2'];
54
- $videoid = $instance['v_id2'];
55
- $videosource = $instance['v_source'];
56
- $videowidth = $instance['v_width2'];
57
- $videoheight = $instance['v_height2'];
58
-
59
- //function to show video in blog sidebar, please look for it below
60
- VSWShowVideo($videosource,$videoid,$autoplaysetting,$videowidth,$videoheight,'false','false');
61
-
62
- if($cap2){
63
- echo "<p class=\"VideoCaption\">$cap2</p>";
64
- }
65
-
66
- echo $after_widget;
67
-
68
- }//end of function widget
69
-
70
-
71
-
72
- //function to update widget setting
73
- function update( $new_instance, $old_instance ) {
74
-
75
- $instance = $old_instance;
76
- $instance['title2'] = strip_tags( $new_instance['title2'] );
77
- $instance['v_width2'] = strip_tags( $new_instance['v_width2'] );
78
- $instance['v_height2'] = strip_tags( $new_instance['v_height2'] );
79
- $instance['v_autoplay2'] = strip_tags( $new_instance['v_autoplay2'] );
80
- $instance['v_id2'] = strip_tags( $new_instance['v_id2'] );
81
- $instance['v_source'] = strip_tags( $new_instance['v_source'] );
82
- $instance['v_cap2'] = $new_instance['v_cap2'];
83
- return $instance;
84
-
85
- }//end of function update
86
-
87
-
88
- //function to create Widget Admin form
89
- function form($instance) {
90
-
91
- $instance = wp_parse_args( (array) $instance, array( 'title2' => '', 'v_width2' => '', 'v_height2' => '',
92
- 'v_autoplay2' => '','v_id2' => '','v_source' => '','v_cap2' => '') );
93
-
94
- $instance['title2'] = strip_tags( $instance['title2'] );
95
- $instance['v_width2'] = strip_tags( $instance['v_width2'] );
96
- $instance['v_height2'] = strip_tags( $instance['v_height2'] );
97
- $instance['v_autoplay2'] = strip_tags( $instance['v_autoplay2'] );
98
- $instance['v_id2'] = strip_tags( $instance['v_id2'] );
99
- $instance['v_source'] = strip_tags( $instance['v_source'] );
100
- $instance['v_cap2'] = $instance['v_cap2'];
101
-
102
- //function to show video in widget admin form fixed width and height, please look for it below
103
- $autoplaysetting = '0';
104
- $videoid = $instance['v_id2'];
105
- $videosource = $instance['v_source'];
106
- $videowidth = null;
107
- $videoheight = null;
108
- //$admin = true // to show video in admin
109
-
110
- VSWShowVideo($videosource,$videoid,$autoplaysetting,$videowidth,$videoheight,'true','false');
111
-
112
- ?>
113
-
114
-
115
- <p>
116
- <label for="<?php echo $this->get_field_id('title2'); ?>">Widget Title:</label>
117
- <input class="widefat" id="<?php echo $this->get_field_id('title2'); ?>" name="<?php echo $this->get_field_name('title2'); ?>"
118
- type="text" value="<?php echo $instance['title2']; ?>" />
119
- </p>
120
-
121
- <p>
122
- <label for="<?php echo $this->get_field_id( 'v_source' ); ?>">Select Video Source:</label>
123
- <select id="<?php echo $this->get_field_id( 'v_source' );?>" name="<?php echo $this->get_field_name( 'v_source' );?>"
124
- class="widefat" style="width:100%;">
125
- <option value='YouTube' <?php if($instance['v_source'] == 'YouTube'){echo 'selected="selected"';}?> >YouTube Video</option>
126
- <option value='Vimeo' <?php if($instance['v_source'] == 'Vimeo'){echo 'selected="selected"';}?> >Vimeo Video</option>
127
- <option value='MySpace' <?php if($instance['v_source'] == 'MySpace'){echo 'selected="selected"';}?> >MySpace Video</option>
128
- <option value='Veoh' <?php if($instance['v_source'] == 'Veoh'){echo 'selected="selected"';}?> >Veoh Video</option>
129
- <option value='Blip' <?php if($instance['v_source'] == 'Blip'){echo 'selected="selected"';}?> >blip.tv Video</option>
130
- <option value='WordPress' <?php if($instance['v_source'] == 'WordPress'){echo 'selected="selected"';}?> >WordPress Video
131
- </option>
132
- <option value='Viddler' <?php if($instance['v_source'] == 'Viddler'){echo 'selected="selected"';}?> >Viddler Video</option>
133
- <option value='DailyMotion' <?php if($instance['v_source'] == 'DailyMotion'){echo 'selected="selected"';}?> >DailyMotion Video </option>
134
- <option value='Revver' <?php if($instance['v_source'] == 'Revver'){echo 'selected="selected"';}?> >Revver Video</option>
135
- <option value='Metacafe' <?php if($instance['v_source'] == 'Metacafe'){echo 'selected="selected"';}?> >Metacafe Video</option>
136
- <option value='Tudou' <?php if($instance['v_source'] == 'Tudou'){echo 'selected="selected"';}?> >Tudou Video</option>
137
- <option value='Youku' <?php if($instance['v_source'] == 'Youku'){echo 'selected="selected"';}?> >Youku Video</option>
138
- <option value='cn6' <?php if($instance['v_source'] == 'cn6'){echo 'selected="selected"';}?> >6.cn Video</option>
139
- <option value='Google' <?php if($instance['v_source'] == 'Google'){echo 'selected="selected"';}?> >Google Video</option>
140
- <option value='Tangle' <?php if($instance['v_source'] == 'Tangle'){echo 'selected="selected"';}?> >Tangle Video</option>
141
- </select>
142
- </p>
143
-
144
- <p>
145
- <label for="<?php echo $this->get_field_id('v_id2'); ?>">Video ID: </label>
146
- <input class="widefat" id="<?php echo $this->get_field_id('v_id2'); ?>"
147
- name="<?php echo $this->get_field_name('v_id2'); ?>" type="text" value="<?php echo $instance['v_id2']; ?>" /></p>
148
-
149
- <p>
150
- <label for="<?php echo $this->get_field_id('v_width2'); ?>">Video Width: </label>
151
- <input class="widefat" id="<?php echo $this->get_field_id('v_width2'); ?>"
152
- name="<?php echo $this->get_field_name('v_width2'); ?>" type="text" value="<?php echo $instance['v_width2']; ?>" />
153
- </p>
154
-
155
- <p>
156
- <label for="<?php echo $this->get_field_id('v_height2'); ?>">Video Height: </label>
157
- <input class="widefat" id="<?php echo $this->get_field_id('v_height2'); ?>"
158
- name="<?php echo $this->get_field_name('v_height2'); ?>" type="text" value="<?php echo $instance['v_height2']; ?>" />
159
- </p>
160
-
161
- <p>
162
- <label for="<?php echo $this->get_field_id('v_cap2'); ?>">Video Caption: </label>
163
- <input class="widefat" id="<?php echo $this->get_field_id('v_cap2'); ?>"
164
- name="<?php echo $this->get_field_name('v_cap2'); ?>" type="text" value="<?php echo $instance['v_cap2']; ?>" />
165
- </p>
166
-
167
-
168
- <p>
169
-
170
- <?php
171
-
172
- // check whether autoplay feature supported by video network
173
- $source = $instance['v_source'];
174
- $msg = "<p>Sorry, auto play option not supported by ".$source."</p>";
175
- switch ($source) {
176
-
177
- case WordPress:
178
- echo $msg;
179
- break;
180
-
181
- case Tudou:
182
- echo $msg;
183
- break;
184
-
185
- case Youku:
186
- echo $msg;
187
- break;
188
-
189
- case Blip:
190
- echo "<p>Sorry, auto play option removed as it is causing error in Internet Explorer</p>";
191
- break;
192
-
193
- case cn6:
194
- echo "<p>Sorry, auto play option not supported by 6.cn</p>";
195
- break;
196
- }
197
-
198
- ?>
199
-
200
- <label for="<?php echo $this->get_field_id( 'v_autoplay2' ); ?>">Auto Play:</label>
201
- <select id="<?php echo $this->get_field_id( 'v_autoplay2' );?>"
202
- name="<?php echo $this->get_field_name( 'v_autoplay2' );?>" class="widefat" style="width:100%;">';
203
- <option value='1' <?php if($instance['v_autoplay2'] == '1'){echo 'selected="selected"';}?>>Yes</option>
204
- <option value='0' <?php if($instance['v_autoplay2'] == '0'){echo 'selected="selected"';}?>>No</option>
205
- </select>
206
- </p>
207
-
208
- <?php
209
-
210
- }//end of function form($instance)
211
-
212
- }//end of Video Sidebar Widget Class
213
-
214
-
215
-
216
- function VSWShowVideo($videosource,$videoid,$autoplaysetting,$videowidth,$videoheight,$admin,$shortcode){
217
-
218
- //admin = true to show in widget admin
219
- //admin = false to show in blog sidebar
220
-
221
- $v_autoplay2 = $autoplaysetting;
222
- $v_id2 = $videoid;
223
- $v_source = $videosource;
224
- $v_width2 = $videowidth;
225
- $v_height2 = $videoheight;
226
-
227
- $source = $v_source;
228
-
229
- //test for source and assign codes accordingly
230
- switch ($source) {
231
-
232
- case null:
233
- $value = null;
234
- $flashvar = null;
235
- $flashvar2 = null;
236
- break;
237
-
238
- case YouTube:
239
- $value = "http://www.youtube.com/v/$v_id2&autoplay=$v_autoplay2&loop=0&rel=0";
240
- $flashvar = null;
241
- $flashvar2 = null;
242
- break;
243
-
244
- case Vimeo:
245
- $value = "http://vimeo.com/moogaloop.swf?clip_id=$v_id2&amp;server=vimeo.com&amp;loop=0&amp;fullscreen=1&amp;autoplay=$v_autoplay2";
246
- $flashvar = null;
247
- $flashvar2 = null;
248
- break;
249
-
250
- case MySpace:
251
- $value = "http://mediaservices.myspace.com/services/media/embed.aspx/m=$v_id2,t=1,mt=video,ap=$v_autoplay2";
252
- $flashvar = null;
253
- $flashvar2 = null;
254
- break;
255
-
256
- case Veoh:
257
- $value = "http://www.veoh.com/static/swf/webplayer/WebPlayer.swf?version=AFrontend.5.4.2.20.1002&";
258
- $value.= "permalinkId=$v_id2&player=videodetailsembedded&id=anonymous&videoAutoPlay=$v_autoplay2";
259
- $flashvar = null;
260
- $flashvar2 = null;
261
- break;
262
-
263
- case Blip:
264
- $value = "http://blip.tv/play/$v_id2";
265
- $flashvar = null;
266
- $flashvar2 = null;
267
- break;
268
-
269
- case WordPress:
270
- $value = "http://v.wordpress.com/$v_id2";
271
- $flashvar = null;
272
- $flashvar2 = null;
273
- break;
274
-
275
- case Viddler:
276
- $value = "http://www.viddler.com/player/$v_id2";
277
- if($v_autoplay2=='1'){
278
- $flashvar = "<param name=\"flashvars\" value=\"autoplay=t\" />\n";
279
- $flashvar2 = 'flashvars="autoplay=t" ';
280
- }
281
- break;
282
-
283
- case DailyMotion:
284
- $value = "http://www.dailymotion.com/swf/$v_id2&autoStart=$v_autoplay2&related=0";
285
- $flashvar = null;
286
- $flashvar2 = null;
287
- break;
288
-
289
-
290
- case Revver:
291
- $value = "http://flash.revver.com/player/1.0/player.swf?mediaId=$v_id2&autoStart=$v_autoplay2";
292
- $flashvar = null;
293
- $flashvar2 = null;
294
- break;
295
-
296
- case Metacafe:
297
- $id = split('/',$v_id2);
298
- $value = "http://www.metacafe.com/fplayer/$id[0]/$id[1].swf";
299
- if($v_autoplay2=='1'){
300
- $flashvar = null;
301
- $flashvar2 = 'flashVars="playerVars=showStats=no|autoPlay=yes|"';
302
- }
303
- break;
304
-
305
- case Tudou:
306
- $value = "$v_id2";
307
- $flashvar = null;
308
- $flashvar2 = null;
309
- break;
310
-
311
- case Youku:
312
- $value = "$v_id2";
313
- $flashvar = null;
314
- $flashvar2 = null;
315
- break;
316
-
317
- case cn6:
318
- $value = "$v_id2";
319
- $flashvar = null;
320
- $flashvar2 = null;
321
- break;
322
-
323
- case Google:
324
- $value = "http://video.google.com/googleplayer.swf?docid=$v_id2&hl=en&fs=true";
325
- if($v_autoplay2=='1'){
326
- $flashvar = null;
327
- $flashvar2 = 'FlashVars="autoPlay=true&playerMode=embedded"';
328
- }
329
- break;
330
-
331
- case Tangle:
332
- $value = "http://www.tangle.com/flash/swf/flvplayer.swf";
333
- if($v_autoplay2=='1'){
334
- $flashvar = null;
335
- $flashvar2 = "FlashVars=\"viewkey=$v_id2&autoplay=$v_autoplay2\"";
336
- }else{
337
- $flashvar = null;
338
- $flashvar2 = "FlashVars=\"viewkey=$v_id2\"";
339
- }
340
- break;
341
-
342
- }
343
-
344
- if($shortcode=="true"){
345
- //added in version 2.3
346
- //return instead of echo video on blog using shortcode
347
- $vsw_code = "\n<object width=\"$v_width2\" height=\"$v_height2\">\n";
348
- $vsw_code .= $flashvar;
349
- $vsw_code .= "<param name=\"allowfullscreen\" value=\"true\" />\n";
350
- $vsw_code .= "<param name=\"allowscriptaccess\" value=\"always\" />\n";
351
- $vsw_code .= "<param name=\"movie\" value=\"$value\" />\n";
352
- $vsw_code .= "<param name=\"wmode\" value=\"transparent\">\n";
353
- $vsw_code .= "<embed src=\"$value\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" ";
354
- $vsw_code .= "allowfullscreen=\"true\" allowscriptaccess=\"always\" ";
355
- $vsw_code .= $flashvar2;
356
- $vsw_code .= "width=\"$v_width2\" height=\"$v_height2\">\n";
357
- $vsw_code .= "</embed>\n";
358
- $vsw_code .= "</object>\n\n";
359
- return $vsw_code;
360
- }
361
- elseif($admin=="true"){
362
- // echo video in admin
363
- echo "\n<object width=\"212\" height=\"172\">\n";
364
- echo $flashvar;
365
- echo "<param name=\"allowfullscreen\" value=\"true\" />\n";
366
- echo "<param name=\"allowscriptaccess\" value=\"always\" />\n";
367
- echo "<param name=\"movie\" value=\"$value\" />\n";
368
- echo "<param name=\"wmode\" value=\"transparent\">\n";
369
- echo "<embed src=\"$value\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" ";
370
- echo "allowfullscreen=\"true\" allowscriptaccess=\"always\" ";
371
- echo $flashvar2;
372
- echo "width=\"212\" height=\"172\">\n";
373
- echo "</embed>\n";
374
- echo "</object>\n\n";
375
-
376
- }else{
377
-
378
- // echo video on blog
379
- echo "\n<object width=\"$v_width2\" height=\"$v_height2\">\n";
380
- echo $flashvar;
381
- echo "<param name=\"allowfullscreen\" value=\"true\" />\n";
382
- echo "<param name=\"allowscriptaccess\" value=\"always\" />\n";
383
- echo "<param name=\"movie\" value=\"$value\" />\n";
384
- echo "<param name=\"wmode\" value=\"transparent\">\n";
385
- echo "<embed src=\"$value\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" ";
386
- echo "allowfullscreen=\"true\" allowscriptaccess=\"always\" ";
387
- echo $flashvar2;
388
- echo "width=\"$v_width2\" height=\"$v_height2\">\n";
389
- echo "</embed>\n";
390
- echo "</object>\n\n";
391
- }
392
-
393
-
394
- }//end of function VSWShowVideo
395
-
396
-
397
-
398
-
399
-
400
-
401
-
402
-
403
-
404
-
405
-
406
- //Random video widget starts here
407
-
408
-
409
- class RandomVideoSidebarWidget extends WP_Widget {
410
-
411
- function RandomVideoSidebarWidget() {
412
- $widget_ops = array( 'classname' => 'randomvideosidebar', 'description' => __('A Random Video Widget. Randomly selects 1 of the 5 preset videos for display', 'randomvideosidebar') );
413
- $control_ops = array( 'width' => 705, 'height' => 600, 'id_base' => 'randomvideosidebar' );
414
- $this->WP_Widget( 'randomvideosidebar', __('Random Video Sidebar Widget', 'randomvideosidebar'), $widget_ops, $control_ops );
415
- }
416
-
417
-
418
- function widget( $args, $instance ) {
419
- extract( $args );
420
-
421
- $RV_title = apply_filters('widget_title', $instance['RV_title'] );
422
- $RV_width = $instance['RV_width'];
423
- $RV_height = $instance['RV_height'];
424
- $RV_autoplay = $instance['RV_autoplay'];
425
- $RV_id1 = $instance['RV_id1'];
426
- $RV_source1 = $instance['RV_source1'];
427
- $RV_cap1 = $instance['RV_cap1'];
428
- $RV_id2 = $instance['RV_id2'];
429
- $RV_source2 = $instance['RV_source2'];
430
- $RV_cap2 = $instance['RV_cap2'];
431
- $RV_id3 = $instance['RV_id3'];
432
- $RV_source3 = $instance['RV_source3'];
433
- $RV_cap3 = $instance['RV_cap3'];
434
- $RV_id4 = $instance['RV_id4'];
435
- $RV_source4 = $instance['RV_source4'];
436
- $RV_cap4 = $instance['RV_cap4'];
437
- $RV_id5 = $instance['RV_id5'];
438
- $RV_source5 = $instance['RV_source5'];
439
- $RV_cap5 = $instance['RV_cap5'];
440
-
441
- echo $before_widget;
442
-
443
- if ( $RV_title )
444
- echo $before_title . $RV_title . $after_title;
445
-
446
- //using rand() to select which video to show
447
-
448
- $selection = rand(1,5);
449
-
450
- switch($selection){
451
-
452
- case 1:
453
- $Embed_id = $RV_id1;
454
- $Embed_source = $RV_source1;
455
- $Embed_cap = $RV_cap1;
456
- break;
457
-
458
- case 2:
459
- $Embed_id = $RV_id2;
460
- $Embed_source = $RV_source2;
461
- $Embed_cap = $RV_cap2;
462
- break;
463
-
464
- case 3:
465
- $Embed_id = $RV_id3;
466
- $Embed_source = $RV_source3;
467
- $Embed_cap = $RV_cap3;
468
- break;
469
-
470
- case 4:
471
- $Embed_id = $RV_id4;
472
- $Embed_source = $RV_source4;
473
- $Embed_cap = $RV_cap4;
474
- break;
475
-
476
- case 5:
477
- $Embed_id = $RV_id5;
478
- $Embed_source = $RV_source5;
479
- $Embed_cap = $RV_cap5;
480
- break;
481
-
482
- }
483
-
484
- //test for empty $Embed_id and empty $Embed_source. if empty,
485
- //assign to same as first video id and source
486
-
487
- If(empty($Embed_id)){
488
- $Embed_id = $RV_id1;
489
- $Embed_source = $RV_source1;
490
- $Embed_cap = $RV_cap1;
491
- }
492
-
493
- $select_source = $Embed_source;
494
-
495
- switch ($select_source) {
496
-
497
- case null:
498
- $rv_value = null;
499
- $rv_flashvar = null;
500
- $rv_flashvar2 = null;
501
- $rv_cap = null;
502
- break;
503
-
504
- case YouTube:
505
- $rv_value = "http://www.youtube.com/v/$Embed_id&autoplay=$RV_autoplay&loop=0&rel=0";
506
- $rv_flashvar = null;
507
- $rv_flashvar2 = null;
508
- $rv_cap = $Embed_cap;
509
- break;
510
-
511
- case Vimeo:
512
- $rv_value = "http://vimeo.com/moogaloop.swf?clip_id=$Embed_id&amp;server=vimeo.com&amp;loop=0&amp;fullscreen=1&amp;autoplay=$RV_autoplay";
513
- $rv_flashvar = null;
514
- $rv_flashvar2 = null;
515
- $rv_cap = $Embed_cap;
516
- break;
517
-
518
- case MySpace:
519
- $rv_value = "http://mediaservices.myspace.com/services/media/embed.aspx/m=$Embed_id,t=1,mt=video,ap=$RV_autoplay";
520
- $rv_flashvar = null;
521
- $rv_flashvar2 = null;
522
- $rv_cap = $Embed_cap;
523
- break;
524
-
525
- case Veoh:
526
- $rv_value = "http://www.veoh.com/static/swf/webplayer/WebPlayer.swf?version=AFrontend.5.4.2.20.1002&permalinkId=$Embed_id";
527
- $rv_value.= "&player=videodetailsembedded&id=anonymous&videoAutoPlay=$RV_autoplay";
528
- $rv_flashvar = null;
529
- $rv_flashvar2 = null;
530
- $rv_cap = $Embed_cap;
531
- break;
532
-
533
- case Blip:
534
- $rv_value = "http://blip.tv/play/$Embed_id";
535
- $rv_flashvar = null;
536
- $rv_flashvar2 = null;
537
- $rv_cap = $Embed_cap;
538
- break;
539
-
540
- case WordPress:
541
- $rv_value = "http://v.wordpress.com/$Embed_id";
542
- $rv_flashvar = null;
543
- $rv_flashvar2 = null;
544
- $rv_cap = $Embed_cap;
545
- break;
546
-
547
- case Viddler:
548
- $rv_value = "http://www.viddler.com/player/$Embed_id";
549
- if($RV_autoplay=='1'){
550
- $rv_flashvar = "<param name=\"flashvars\" value=\"autoplay=t\" />\n";
551
- $rv_flashvar2 = 'flashvars="autoplay=t" ';
552
- }
553
- $rv_cap = $Embed_cap;
554
- break;
555
-
556
- case DailyMotion:
557
- $rv_value = "http://www.dailymotion.com/swf/$Embed_id&autoStart=$RV_autoplay&related=0";
558
- $rv_flashvar = null;
559
- $rv_flashvar2 = null;
560
- $rv_cap = $Embed_cap;
561
- break;
562
-
563
-
564
- case Revver:
565
- $rv_value = "http://flash.revver.com/player/1.0/player.swf?mediaId=$Embed_id&autoStart=$RV_autoplay";
566
- $rv_flashvar = null;
567
- $rv_flashvar2 = null;
568
- $rv_cap = $Embed_cap;
569
- break;
570
-
571
- case Metacafe:
572
- $rid = split('/',$Embed_id);
573
- $rv_value = "http://www.metacafe.com/fplayer/$rid[0]/$rid[1].swf";
574
- if($RV_autoplay=='1'){
575
- $rv_flashvar = null;
576
- $rv_flashvar2 = 'flashVars="playerVars=showStats=no|autoPlay=yes|"';
577
- }
578
- $rv_cap = $Embed_cap;
579
- break;
580
-
581
- case Tudou:
582
- $rv_value = "$Embed_id";
583
- $rv_flashvar = null;
584
- $rv_flashvar2 = null;
585
- $rv_cap = $Embed_cap;
586
- break;
587
-
588
- case Youku:
589
- $rv_value = "$Embed_id";
590
- $rv_flashvar = null;
591
- $rv_flashvar2 = null;
592
- $rv_cap = $Embed_cap;
593
- break;
594
-
595
- case cn6:
596
- $rv_value = "$Embed_id";
597
- $rv_flashvar = null;
598
- $rv_flashvar2 = null;
599
- $rv_cap = $Embed_cap;
600
- break;
601
-
602
- case Google:
603
- $rv_value = "http://video.google.com/googleplayer.swf?docid=$Embed_id&hl=en&fs=true";
604
- if($RV_autoplay=='1'){
605
- $rv_flashvar = null;
606
- $rv_flashvar2 = 'FlashVars="autoPlay=true&playerMode=embedded"';
607
- }
608
- $rv_cap = $Embed_cap;
609
- break;
610
-
611
- case Tangle:
612
- $rv_value = "http://www.tangle.com/flash/swf/flvplayer.swf";
613
- if($RV_autoplay=='1'){
614
- $rv_flashvar = null;
615
- $rv_flashvar2 = "FlashVars=\"viewkey=$Embed_id&autoplay=$RV_autoplay\"";
616
- }else{
617
- $rv_flashvar = null;
618
- $rv_flashvar2 = "FlashVars=\"viewkey=$Embed_id\"";
619
- }
620
- $rv_cap = $Embed_cap;
621
- break;
622
-
623
-
624
-
625
- }
626
-
627
-
628
-
629
- echo "\n<object width=\"$RV_width\" height=\"$RV_height\">\n";
630
- echo $rv_flashvar;
631
- echo "<param name=\"allowfullscreen\" value=\"true\" />\n";
632
- echo "<param name=\"allowscriptaccess\" value=\"always\" />\n";
633
- echo "<param name=\"movie\" value=\"$rv_value\" />\n";
634
- echo "<param name=\"wmode\" value=\"transparent\">\n";
635
- echo "<embed src=\"$rv_value\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" ";
636
- echo "allowfullscreen=\"true\" allowscriptaccess=\"always\" ";
637
- echo $rv_flashvar2;
638
- echo "width=\"$RV_width\" height=\"$RV_height\">\n";
639
- echo "</embed>\n";
640
- echo "</object>\n\n";
641
- echo "<p class=\"VideoCaption\">$rv_cap</p>";
642
-
643
-
644
- echo $after_widget;
645
- }
646
-
647
-
648
- function update( $new_instance, $old_instance ) {
649
- $instance = $old_instance;
650
- $instance['RV_title'] = strip_tags( $new_instance['RV_title'] );
651
- $instance['RV_width'] = strip_tags( $new_instance['RV_width'] );
652
- $instance['RV_height'] = strip_tags( $new_instance['RV_height'] );
653
- $instance['RV_autoplay'] = strip_tags( $new_instance['RV_autoplay'] );
654
- $instance['RV_id1'] = strip_tags( $new_instance['RV_id1'] );
655
- $instance['RV_source1'] = strip_tags( $new_instance['RV_source1'] );
656
- $instance['RV_cap1'] = $new_instance['RV_cap1'];
657
- $instance['RV_id2'] = strip_tags( $new_instance['RV_id2'] );
658
- $instance['RV_source2'] = strip_tags( $new_instance['RV_source2'] );
659
- $instance['RV_cap2'] = $new_instance['RV_cap2'];
660
- $instance['RV_id3'] = strip_tags( $new_instance['RV_id3'] );
661
- $instance['RV_source3'] = strip_tags( $new_instance['RV_source3'] );
662
- $instance['RV_cap3'] = $new_instance['RV_cap3'];
663
- $instance['RV_id4'] = strip_tags( $new_instance['RV_id4'] );
664
- $instance['RV_source4'] = strip_tags( $new_instance['RV_source4'] );
665
- $instance['RV_cap4'] = $new_instance['RV_cap4'];
666
- $instance['RV_id5'] = strip_tags( $new_instance['RV_id5'] );
667
- $instance['RV_source5'] = strip_tags( $new_instance['RV_source5'] );
668
- $instance['RV_cap5'] = $new_instance['RV_cap5'];
669
- return $instance;
670
- }
671
-
672
-
673
- function form($instance) {
674
- $instance = wp_parse_args( (array) $instance, array( 'RV_title' => '', 'RV_width' => '', 'RV_height' => '', 'RV_autoplay' => '','RV_id1' => '','RV_source1' => '','RV_cap1' => '', 'RV_id2' => '','RV_source2' => '','RV_cap2' => '', 'RV_id3' => '','RV_source3' => '','RV_cap3' => '', 'RV_id4' => '','RV_source4' => '','RV_cap4' => '', 'RV_id5' => '','RV_source5' => '','RV_cap5' => '') );
675
-
676
- $instance['RV_title'] = strip_tags( $instance['RV_title'] );
677
- $instance['RV_width'] = strip_tags( $instance['RV_width'] );
678
- $instance['RV_height'] = strip_tags( $instance['RV_height'] );
679
- $instance['RV_autoplay'] = strip_tags( $instance['RV_autoplay'] );
680
- $instance['RV_id1'] = strip_tags( $instance['RV_id1'] );
681
- $instance['RV_source1'] = strip_tags( $instance['RV_source1'] );
682
- $instance['RV_cap1'] = $instance['RV_cap1'];
683
- $instance['RV_id2'] = strip_tags( $instance['RV_id2'] );
684
- $instance['RV_source2'] = strip_tags( $instance['RV_source2'] );
685
- $instance['RV_cap2'] = $instance['RV_cap2'];
686
- $instance['RV_id3'] = strip_tags( $instance['RV_id3'] );
687
- $instance['RV_source3'] = strip_tags( $instance['RV_source3'] );
688
- $instance['RV_cap3'] = $instance['RV_cap3'];
689
- $instance['RV_id4'] = strip_tags( $instance['RV_id4'] );
690
- $instance['RV_source4'] = strip_tags( $instance['RV_source4'] );
691
- $instance['RV_cap4'] = $instance['RV_cap4'];
692
- $instance['RV_id5'] = strip_tags( $instance['RV_id5'] );
693
- $instance['RV_source5'] = strip_tags( $instance['RV_source5'] );
694
- $instance['RV_cap5'] = $instance['RV_cap5'];
695
 
 
 
696
 
697
- ?>
698
- <div style="width:220px;height:350px;float:left;margin:0px 15px 20px 5px">
699
- <h2>General Settings</h2>
700
- <!--Title -->
701
- <p>
702
- <label for="<?php echo $this->get_field_id('RV_title'); ?>">Widget Title:</label>
703
- <input class="widefat" id="<?php echo $this->get_field_id('RV_title'); ?>" name="<?php echo $this->get_field_name('RV_title'); ?>" type="text" value="<?php echo $instance['RV_title']; ?>" />
704
- </p>
705
 
706
- <!--Width -->
707
- <p>
708
- <label for="<?php echo $this->get_field_id('RV_width'); ?>">Video Width: </label>
709
- <input class="widefat" id="<?php echo $this->get_field_id('RV_width'); ?>" name="<?php echo $this->get_field_name('RV_width'); ?>" type="text" value="<?php echo $instance['RV_width']; ?>" />
710
- </p>
711
 
712
- <!--Height -->
713
- <p>
714
- <label for="<?php echo $this->get_field_id('RV_height'); ?>">Video Height: </label>
715
- <input class="widefat" id="<?php echo $this->get_field_id('RV_height'); ?>" name="<?php echo $this->get_field_name('RV_height'); ?>" type="text" value="<?php echo $instance['RV_height']; ?>" />
716
- </p>
717
-
718
- <!--auto play -->
719
- <p>
720
- <label for="<?php echo $this->get_field_id( 'RV_autoplay' ); ?>">Auto Play:</label>
721
- <select id="<?php echo $this->get_field_id( 'RV_autoplay' );?>" name="<?php echo $this->get_field_name( 'RV_autoplay' );?>" class="widefat" style="width:100%;">';
722
- <option value='1' <?php if($instance['RV_autoplay'] == '1'){echo 'selected="selected"';}?>>Yes</option>
723
- <option value='0' <?php if($instance['RV_autoplay'] == '0'){echo 'selected="selected"';}?>>No</option>
724
- </select>
725
- </p>
726
- <p>Please fill up settings before clicking on save to display video.</p>
727
- </div>
728
-
729
- <div style="width:220px;height:350px;float:left;margin:0px 15px 20px 0px">
730
- <!--first video setting -->
731
- <h2>Video 1</h2>
732
- <?php
733
- //show video in Random Video Widget Admin
734
- $autoplaysetting = '0';
735
- $videoid = $instance['RV_id1'];
736
- $videosource = $instance['RV_source1'];
737
- $videowidth = null;
738
- $videoheight = null;
739
- //$admin = true // to show video in admin
740
-
741
- VSWShowVideo($videosource,$videoid,$autoplaysetting,$videowidth,$videoheight,'true','false');
742
- ?>
743
- <p>
744
- <label for="<?php echo $this->get_field_id( 'RV_source1' ); ?>">Select Video 1 Source:</label>
745
- <select id="<?php echo $this->get_field_id( 'RV_source1' );?>" name="<?php echo $this->get_field_name( 'RV_source1' );?>" class="widefat" style="width:100%;">
746
- <option value='YouTube' <?php if($instance['RV_source1'] == 'YouTube'){echo 'selected="selected"';}?> >YouTube Video</option>
747
- <option value='Vimeo' <?php if($instance['RV_source1'] == 'Vimeo'){echo 'selected="selected"';}?> >Vimeo Video</option>
748
- <option value='MySpace' <?php if($instance['RV_source1'] == 'MySpace'){echo 'selected="selected"';}?> >MySpace Video</option>
749
- <option value='Veoh' <?php if($instance['RV_source1'] == 'Veoh'){echo 'selected="selected"';}?> >Veoh Video</option>
750
- <option value='Blip' <?php if($instance['RV_source1'] == 'Blip'){echo 'selected="selected"';}?> >blip.tv Video</option>
751
- <option value='WordPress' <?php if($instance['RV_source1'] == 'WordPress'){echo 'selected="selected"';}?> >WordPress Video</option>
752
- <option value='Viddler' <?php if($instance['RV_source1'] == 'Viddler'){echo 'selected="selected"';}?> >Viddler Video</option>
753
- <option value='DailyMotion' <?php if($instance['RV_source1'] == 'DailyMotion'){echo 'selected="selected"';}?> >DailyMotion Video</option>
754
- <option value='Revver' <?php if($instance['RV_source1'] == 'Revver'){echo 'selected="selected"';}?> >Revver Video</option>
755
- <option value='Metacafe' <?php if($instance['RV_source1'] == 'Metacafe'){echo 'selected="selected"';}?> >Metacafe Video</option>
756
- <option value='Tudou' <?php if($instance['RV_source1'] == 'Tudou'){echo 'selected="selected"';}?> >Tudou Video</option>
757
- <option value='Youku' <?php if($instance['RV_source1'] == 'Youku'){echo 'selected="selected"';}?> >Youku Video</option>
758
- <option value='cn6' <?php if($instance['RV_source1'] == 'cn6'){echo 'selected="selected"';}?> >6.cn Video</option>
759
- <option value='Google' <?php if($instance['RV_source1'] == 'Google'){echo 'selected="selected"';}?> >Google Video</option>
760
- <option value='Tangle' <?php if($instance['RV_source1'] == 'Tangle'){echo 'selected="selected"';}?> >Tangle Video</option>
761
- </select>
762
- </p>
763
-
764
- <p>
765
- <label for="<?php echo $this->get_field_id('RV_id1'); ?>">Video 1 ID: </label>
766
- <input class="widefat" id="<?php echo $this->get_field_id('RV_id1'); ?>" name="<?php echo $this->get_field_name('RV_id1'); ?>" type="text" value="<?php echo $instance['RV_id1']; ?>" /></p>
767
-
768
- <p>
769
- <label for="<?php echo $this->get_field_id('RV_cap1'); ?>">Video Caption: </label>
770
- <input class="widefat" id="<?php echo $this->get_field_id('RV_cap1'); ?>" name="<?php echo $this->get_field_name('RV_cap1'); ?>" type="text" value="<?php echo $instance['RV_cap1']; ?>" /></p>
771
-
772
- </div>
773
- <div style="width:220px;height:350px;float:left;margin:0px 15px 20px 0px">
774
-
775
- <!--second video setting -->
776
- <h2>Video 2</h2>
777
- <?php
778
- //show video in Random Video Widget Admin
779
- $autoplaysetting = '0';
780
- $videoid = $instance['RV_id2'];
781
- $videosource = $instance['RV_source2'];
782
- $videowidth = null;
783
- $videoheight = null;
784
- //$admin = true // to show video in admin
785
-
786
- VSWShowVideo($videosource,$videoid,$autoplaysetting,$videowidth,$videoheight,'true','false');
787
- ?>
788
- <p>
789
- <label for="<?php echo $this->get_field_id( 'RV_source2' ); ?>">Select Video 2 Source:</label>
790
- <select id="<?php echo $this->get_field_id( 'RV_source2' );?>" name="<?php echo $this->get_field_name( 'RV_source2' );?>" class="widefat" style="width:100%;">
791
- <option value='YouTube' <?php if($instance['RV_source2'] == 'YouTube'){echo 'selected="selected"';}?> >YouTube Video</option>
792
- <option value='Vimeo' <?php if($instance['RV_source2'] == 'Vimeo'){echo 'selected="selected"';}?> >Vimeo Video</option>
793
- <option value='MySpace' <?php if($instance['RV_source2'] == 'MySpace'){echo 'selected="selected"';}?> >MySpace Video</option>
794
- <option value='Veoh' <?php if($instance['RV_source2'] == 'Veoh'){echo 'selected="selected"';}?> >Veoh Video</option>
795
- <option value='Blip' <?php if($instance['RV_source2'] == 'Blip'){echo 'selected="selected"';}?> >blip.tv Video</option>
796
- <option value='WordPress' <?php if($instance['RV_source2'] == 'WordPress'){echo 'selected="selected"';}?> >WordPress Video</option>
797
- <option value='Viddler' <?php if($instance['RV_source2'] == 'Viddler'){echo 'selected="selected"';}?> >Viddler Video</option>
798
- <option value='DailyMotion' <?php if($instance['RV_source2'] == 'DailyMotion'){echo 'selected="selected"';}?> >DailyMotion Video</option>
799
- <option value='Revver' <?php if($instance['RV_source2'] == 'Revver'){echo 'selected="selected"';}?> >Revver Video</option>
800
- <option value='Metacafe' <?php if($instance['RV_source2'] == 'Metacafe'){echo 'selected="selected"';}?> >Metacafe Video</option>
801
- <option value='Tudou' <?php if($instance['RV_source2'] == 'Tudou'){echo 'selected="selected"';}?> >Tudou Video</option>
802
- <option value='Youku' <?php if($instance['RV_source2'] == 'Youku'){echo 'selected="selected"';}?> >Youku Video</option>
803
- <option value='cn6' <?php if($instance['RV_source2'] == 'cn6'){echo 'selected="selected"';}?> >6.cn Video</option>
804
- <option value='Google' <?php if($instance['RV_source2'] == 'Google'){echo 'selected="selected"';}?> >Google Video</option>
805
- <option value='Tangle' <?php if($instance['RV_source2'] == 'Tangle'){echo 'selected="selected"';}?> >Tangle Video</option>
806
- </select>
807
- </p>
808
-
809
- <p>
810
- <label for="<?php echo $this->get_field_id('RV_id2'); ?>">Video 2 ID: </label>
811
- <input class="widefat" id="<?php echo $this->get_field_id('RV_id2'); ?>" name="<?php echo $this->get_field_name('RV_id2'); ?>" type="text" value="<?php echo $instance['RV_id2']; ?>" /></p>
812
-
813
- <p>
814
- <label for="<?php echo $this->get_field_id('RV_cap2'); ?>">Video Caption: </label>
815
- <input class="widefat" id="<?php echo $this->get_field_id('RV_cap2'); ?>" name="<?php echo $this->get_field_name('RV_cap2'); ?>" type="text" value="<?php echo $instance['RV_cap2']; ?>" /></p>
816
-
817
- </div>
818
- <div style="width:220px;height:350px;float:left;margin:0px 15px 20px 0px">
819
-
820
- <!--third video setting -->
821
- <h2>Video 3</h2>
822
- <?php
823
- //show video in Random Video Widget Admin
824
- $autoplaysetting = '0';
825
- $videoid = $instance['RV_id3'];
826
- $videosource = $instance['RV_source3'];
827
- $videowidth = null;
828
- $videoheight = null;
829
- //$admin = true // to show video in admin
830
-
831
- VSWShowVideo($videosource,$videoid,$autoplaysetting,$videowidth,$videoheight,'true','false');
832
- ?>
833
- <p>
834
- <label for="<?php echo $this->get_field_id( 'RV_source3' ); ?>">Select Video 3 Source:</label>
835
- <select id="<?php echo $this->get_field_id( 'RV_source3' );?>" name="<?php echo $this->get_field_name( 'RV_source3' );?>" class="widefat" style="width:100%;">
836
- <option value='YouTube' <?php if($instance['RV_source3'] == 'YouTube'){echo 'selected="selected"';}?> >YouTube Video</option>
837
- <option value='Vimeo' <?php if($instance['RV_source3'] == 'Vimeo'){echo 'selected="selected"';}?> >Vimeo Video</option>
838
- <option value='MySpace' <?php if($instance['RV_source3'] == 'MySpace'){echo 'selected="selected"';}?> >MySpace Video</option>
839
- <option value='Veoh' <?php if($instance['RV_source3'] == 'Veoh'){echo 'selected="selected"';}?> >Veoh Video</option>
840
- <option value='Blip' <?php if($instance['RV_source3'] == 'Blip'){echo 'selected="selected"';}?> >blip.tv Video</option>
841
- <option value='WordPress' <?php if($instance['RV_source3'] == 'WordPress'){echo 'selected="selected"';}?> >WordPress Video</option>
842
- <option value='Viddler' <?php if($instance['RV_source3'] == 'Viddler'){echo 'selected="selected"';}?> >Viddler Video</option>
843
- <option value='DailyMotion' <?php if($instance['RV_source3'] == 'DailyMotion'){echo 'selected="selected"';}?> >DailyMotion Video</option>
844
- <option value='Revver' <?php if($instance['RV_source3'] == 'Revver'){echo 'selected="selected"';}?> >Revver Video</option>
845
- <option value='Metacafe' <?php if($instance['RV_source3'] == 'Metacafe'){echo 'selected="selected"';}?> >Metacafe Video</option>
846
- <option value='Tudou' <?php if($instance['RV_source3'] == 'Tudou'){echo 'selected="selected"';}?> >Tudou Video</option>
847
- <option value='Youku' <?php if($instance['RV_source3'] == 'Youku'){echo 'selected="selected"';}?> >Youku Video</option>
848
- <option value='cn6' <?php if($instance['RV_source3'] == 'cn6'){echo 'selected="selected"';}?> >6.cn Video</option>
849
- <option value='Google' <?php if($instance['RV_source3'] == 'Google'){echo 'selected="selected"';}?> >Google Video</option>
850
- <option value='Tangle' <?php if($instance['RV_source3'] == 'Tangle'){echo 'selected="selected"';}?> >Tangle Video</option>
851
- </select>
852
- </p>
853
-
854
- <p>
855
- <label for="<?php echo $this->get_field_id('RV_id3'); ?>">Video 3 ID: </label>
856
- <input class="widefat" id="<?php echo $this->get_field_id('RV_id3'); ?>" name="<?php echo $this->get_field_name('RV_id3'); ?>" type="text" value="<?php echo $instance['RV_id3']; ?>" /></p>
857
-
858
- <p>
859
- <label for="<?php echo $this->get_field_id('RV_cap3'); ?>">Video Caption: </label>
860
- <input class="widefat" id="<?php echo $this->get_field_id('RV_cap3'); ?>" name="<?php echo $this->get_field_name('RV_cap3'); ?>" type="text" value="<?php echo $instance['RV_cap3']; ?>" /></p>
861
-
862
-
863
- </div>
864
- <div style="width:220px;height:350px;float:left;margin:0px 15px 20px 5px">
865
-
866
- <!--fourth video setting -->
867
- <h2>Video 4</h2>
868
- <?php
869
- //show video in Random Video Widget Admin
870
- $autoplaysetting = '0';
871
- $videoid = $instance['RV_id4'];
872
- $videosource = $instance['RV_source4'];
873
- $videowidth = null;
874
- $videoheight = null;
875
- //$admin = true // to show video in admin
876
-
877
- VSWShowVideo($videosource,$videoid,$autoplaysetting,$videowidth,$videoheight,'true','false');
878
- ?>
879
- <p>
880
- <label for="<?php echo $this->get_field_id( 'RV_source4' ); ?>">Select Video 4 Source:</label>
881
- <select id="<?php echo $this->get_field_id( 'RV_source4' );?>" name="<?php echo $this->get_field_name( 'RV_source4' );?>" class="widefat" style="width:100%;">
882
- <option value='YouTube' <?php if($instance['RV_source4'] == 'YouTube'){echo 'selected="selected"';}?> >YouTube Video</option>
883
- <option value='Vimeo' <?php if($instance['RV_source4'] == 'Vimeo'){echo 'selected="selected"';}?> >Vimeo Video</option>
884
- <option value='MySpace' <?php if($instance['RV_source4'] == 'MySpace'){echo 'selected="selected"';}?> >MySpace Video</option>
885
- <option value='Veoh' <?php if($instance['RV_source4'] == 'Veoh'){echo 'selected="selected"';}?> >Veoh Video</option>
886
- <option value='Blip' <?php if($instance['RV_source4'] == 'Blip'){echo 'selected="selected"';}?> >blip.tv Video</option>
887
- <option value='WordPress' <?php if($instance['RV_source4'] == 'WordPress'){echo 'selected="selected"';}?> >WordPress Video</option>
888
- <option value='Viddler' <?php if($instance['RV_source4'] == 'Viddler'){echo 'selected="selected"';}?> >Viddler Video</option>
889
- <option value='DailyMotion' <?php if($instance['RV_source4'] == 'DailyMotion'){echo 'selected="selected"';}?> >DailyMotion Video</option>
890
- <option value='Revver' <?php if($instance['RV_source4'] == 'Revver'){echo 'selected="selected"';}?> >Revver Video</option>
891
- <option value='Metacafe' <?php if($instance['RV_source4'] == 'Metacafe'){echo 'selected="selected"';}?> >Metacafe Video</option>
892
- <option value='Tudou' <?php if($instance['RV_source4'] == 'Tudou'){echo 'selected="selected"';}?> >Tudou Video</option>
893
- <option value='Youku' <?php if($instance['RV_source4'] == 'Youku'){echo 'selected="selected"';}?> >Youku Video</option>
894
- <option value='cn6' <?php if($instance['RV_source4'] == 'cn6'){echo 'selected="selected"';}?> >6.cn Video</option>
895
- <option value='Google' <?php if($instance['RV_source4'] == 'Google'){echo 'selected="selected"';}?> >Google Video</option>
896
- <option value='Tangle' <?php if($instance['RV_source4'] == 'Tangle'){echo 'selected="selected"';}?> >Tangle Video</option>
897
- </select>
898
- </p>
899
-
900
- <p>
901
- <label for="<?php echo $this->get_field_id('RV_id4'); ?>">Video 4 ID: </label>
902
- <input class="widefat" id="<?php echo $this->get_field_id('RV_id4'); ?>" name="<?php echo $this->get_field_name('RV_id4'); ?>" type="text" value="<?php echo $instance['RV_id4']; ?>" /></p>
903
-
904
- <p>
905
- <label for="<?php echo $this->get_field_id('RV_cap4'); ?>">Video Caption: </label>
906
- <input class="widefat" id="<?php echo $this->get_field_id('RV_cap4'); ?>" name="<?php echo $this->get_field_name('RV_cap4'); ?>" type="text" value="<?php echo $instance['RV_cap4']; ?>" /></p>
907
-
908
- </div>
909
- <div style="width:220px;height:350px;float:left;margin:0px 15px 20px 0px">
910
-
911
- <!--fifth video setting -->
912
- <h2>Video 5</h2>
913
- <?php
914
- //show video in Random Video Widget Admin
915
- $autoplaysetting = '0';
916
- $videoid = $instance['RV_id5'];
917
- $videosource = $instance['RV_source5'];
918
- $videowidth = null;
919
- $videoheight = null;
920
- //$admin = true // to show video in admin
921
-
922
- VSWShowVideo($videosource,$videoid,$autoplaysetting,$videowidth,$videoheight,'true','false');
923
- ?>
924
- <p>
925
- <label for="<?php echo $this->get_field_id( 'RV_source5' ); ?>">Select Video 5 Source:</label>
926
- <select id="<?php echo $this->get_field_id( 'RV_source5' );?>" name="<?php echo $this->get_field_name( 'RV_source5' );?>" class="widefat" style="width:100%;">
927
- <option value='YouTube' <?php if($instance['RV_source5'] == 'YouTube'){echo 'selected="selected"';}?> >YouTube Video</option>
928
- <option value='Vimeo' <?php if($instance['RV_source5'] == 'Vimeo'){echo 'selected="selected"';}?> >Vimeo Video</option>
929
- <option value='MySpace' <?php if($instance['RV_source5'] == 'MySpace'){echo 'selected="selected"';}?> >MySpace Video</option>
930
- <option value='Veoh' <?php if($instance['RV_source5'] == 'Veoh'){echo 'selected="selected"';}?> >Veoh Video</option>
931
- <option value='Blip' <?php if($instance['RV_source5'] == 'Blip'){echo 'selected="selected"';}?> >blip.tv Video</option>
932
- <option value='WordPress' <?php if($instance['RV_source5'] == 'WordPress'){echo 'selected="selected"';}?> >WordPress Video</option>
933
- <option value='Viddler' <?php if($instance['RV_source5'] == 'Viddler'){echo 'selected="selected"';}?> >Viddler Video</option>
934
- <option value='DailyMotion' <?php if($instance['RV_source5'] == 'DailyMotion'){echo 'selected="selected"';}?> >DailyMotion Video</option>
935
- <option value='Revver' <?php if($instance['RV_source5'] == 'Revver'){echo 'selected="selected"';}?> >Revver Video</option>
936
- <option value='Metacafe' <?php if($instance['RV_source5'] == 'Metacafe'){echo 'selected="selected"';}?> >Metacafe Video</option>
937
- <option value='Tudou' <?php if($instance['RV_source5'] == 'Tudou'){echo 'selected="selected"';}?> >Tudou Video</option>
938
- <option value='Youku' <?php if($instance['RV_source5'] == 'Youku'){echo 'selected="selected"';}?> >Youku Video</option>
939
- <option value='cn6' <?php if($instance['RV_source5'] == 'cn6'){echo 'selected="selected"';}?> >6.cn Video</option>
940
- <option value='Google' <?php if($instance['RV_source5'] == 'Google'){echo 'selected="selected"';}?> >Google Video</option>
941
- <option value='Tangle' <?php if($instance['RV_source5'] == 'Tangle'){echo 'selected="selected"';}?> >Tangle Video</option>
942
- </select>
943
- </p>
944
-
945
- <p>
946
- <label for="<?php echo $this->get_field_id('RV_id5'); ?>">Video 5 ID: </label>
947
- <input class="widefat" id="<?php echo $this->get_field_id('RV_id5'); ?>" name="<?php echo $this->get_field_name('RV_id5'); ?>" type="text" value="<?php echo $instance['RV_id5']; ?>" /></p>
948
-
949
- <p>
950
- <label for="<?php echo $this->get_field_id('RV_cap5'); ?>">Video Caption: </label>
951
- <input class="widefat" id="<?php echo $this->get_field_id('RV_cap5'); ?>" name="<?php echo $this->get_field_name('RV_cap5'); ?>" type="text" value="<?php echo $instance['RV_cap5']; ?>" /></p>
952
-
953
- </div>
954
- <p style="clear:both"></p>
955
-
956
-
957
- <?php
958
-
959
- }
960
-
961
- }
962
- //sdded in version 2.3
963
- //create shortcode to use WP_WIDGET class to echo out video
964
- //[vsw id="123456" source="vimeo" width="400" height="300" autoplay="no"]
965
- function vsw_show_video($atts, $content = null) {
966
- extract(shortcode_atts(array(
967
- "id" => ' ',
968
- "source" => ' ',
969
- "width" => ' ',
970
- "height" => ' ',
971
- "autoplay" => ' ',
972
- ), $atts));
973
-
974
- return vsw_show_video_class($id,$source,$width,$height,$autoplay);
975
- }
976
-
977
- add_shortcode("vsw", "vsw_show_video");
978
-
979
- //function to be used in shortcode or directly in theme
980
- //uses the_widget WordPress Function found in widgets.php
981
- function vsw_show_video_class($id,$source,$width,$height,$autoplay){
982
-
983
- $vsw_id = $id;
984
- $vsw_width = $width;
985
- $vsw_height = $height;
986
-
987
- //convert string of source to lowercase
988
- $source = strtolower($source);
989
-
990
- //should have used all lowercase in previous functions
991
- //now have to switch it.
992
- switch ($source) {
993
-
994
- case null:
995
- $vsw_source = null;
996
- break;
997
-
998
- case youtube:
999
- $vsw_source = YouTube;
1000
- break;
1001
-
1002
- case vimeo:
1003
- $vsw_source = Vimeo;
1004
- break;
1005
-
1006
- case myspace:
1007
- $vsw_source = MySpace;
1008
- break;
1009
-
1010
- case veoh:
1011
- $vsw_source = Veoh;
1012
- break;
1013
-
1014
- case bliptv:
1015
- $vsw_source = Blip;
1016
- break;
1017
-
1018
- case wordpress:
1019
- $vsw_source = WordPress;
1020
- break;
1021
-
1022
- case viddler:
1023
- $vsw_source = Viddler;
1024
- break;
1025
-
1026
- case dailymotion:
1027
- $vsw_source = DailyMotion;
1028
- break;
1029
-
1030
-
1031
- case revver:
1032
- $vsw_source = Revver;
1033
- break;
1034
-
1035
- case metacafe:
1036
- $vsw_source = Metacafe;
1037
- break;
1038
-
1039
- case tudou:
1040
- $vsw_source = Tudou;
1041
- break;
1042
-
1043
- case youku:
1044
- $vsw_source = Youku;
1045
- break;
1046
-
1047
- case cn6:
1048
- $vsw_source = cn6;
1049
- break;
1050
-
1051
- case google:
1052
- $vsw_source = Google;
1053
- break;
1054
-
1055
- case tangle:
1056
- $vsw_source = Tangle;
1057
- break;
1058
-
1059
- }
1060
-
1061
- //string to lowercase
1062
- $autoplay = strtolower($autoplay);
1063
-
1064
- //switch autoplay yes or no to 1 or 0
1065
- switch ($autoplay) {
1066
-
1067
- case null:
1068
- $vsw_autoplay = 0;
1069
- break;
1070
-
1071
- case no:
1072
- $vsw_autoplay = 0;
1073
- break;
1074
-
1075
- case yes:
1076
- $vsw_autoplay = 1;
1077
- break;
1078
-
1079
- }
1080
-
1081
-
1082
- $vsw_code = VSWShowVideo($vsw_source,$vsw_id,$vsw_autoplay,$vsw_width,$vsw_height,'false','true');
1083
-
1084
- return $vsw_code;
1085
-
1086
- }
1087
-
1088
- //add tinymce button to editor
1089
- function dd_vsw_addbuttons() {
1090
- // Don't bother doing this stuff if the current user lacks permissions
1091
- if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') )
1092
- return;
1093
-
1094
- // Add only in Rich Editor mode
1095
- if ( get_user_option('rich_editing') == 'true') {
1096
- add_filter("mce_external_plugins", "dd_vsw_tinymce_plugin");
1097
- add_filter('mce_buttons', 'dd_vsw_button');
1098
- }
1099
- }
1100
-
1101
- function dd_vsw_button($tiny_buttons) {
1102
- array_push($tiny_buttons, "vsw");
1103
- return $tiny_buttons;
1104
- }
1105
-
1106
- // determine absolute url path of editor_plugin.js
1107
- function dd_vsw_plugin_url($type) {
1108
- //check if defined WordPress Plugins URL
1109
- if (defined('WP_PLUGINS_URL')) {
1110
-
1111
- return WP_PLUGINS_URL."/". $type ."/editor_plugin.js";
1112
-
1113
- }else{
1114
- //if not assumme it is default location.
1115
- return "../../../wp-content/plugins/". $type ."/editor_plugin.js";
1116
-
1117
  }
 
 
 
1118
  }
1119
 
1120
- // Load the TinyMCE plugin : editor_plugin.js (wp2.5)
1121
- function dd_vsw_tinymce_plugin($plugin_array) {
1122
- $path = dd_vsw_plugin_url("video-sidebar-widgets");
1123
- $plugin_array['vsw'] = $path;
1124
- return $plugin_array;
1125
- }
1126
-
1127
- // init process for button control
1128
- add_action('init', 'dd_vsw_addbuttons');
1129
-
1130
-
1131
-
1132
  ?>
2
  /*
3
  Plugin Name: Video Sidebar Widgets
4
  Plugin URI: http://denzeldesigns.com/wordpress-plugins/video-sidebar-widgets/
5
+ Version: 4.0
6
  Description: Video Sidebar Widgets to display videos such as Vimeo, YouTube, MySpace Videos etc. Now with added shortcode and quicktag to embed video in post and page content.
7
  Author: Denzel Chia
8
  Author URI: http://denzeldesigns.com/
9
  */
10
 
11
+ //load helper functions
12
+ require_once(dirname(__FILE__) . "/helper-functions.php");
13
 
14
+ //Admin Settings
15
+ require_once(dirname(__FILE__) . "/vsw_admin_settings.php");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
+ //Tinymce Editor Button
18
+ require_once(dirname(__FILE__) . "/vsw_tinymce/vsw_tinymce.php");
19
 
20
+ // Video Sidebar Widget
21
+ require_once(dirname(__FILE__) . "/class-videosidebarwidget.php");
 
 
 
 
 
 
22
 
23
+ // Random Video Widget
24
+ require_once(dirname(__FILE__) . "/class-randomvideosidebarwidget.php");
 
 
 
25
 
26
+ //function to register Video Sidebar Widget and Random Video Sidebar Widget
27
+ function load_video_sidebar_widgets(){
28
+ $options = get_option('vsw_plugin_options');
29
+ if(empty($options['hide_vsw'])){
30
+ register_widget('VideoSidebarWidget');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  }
32
+ if(empty($options['hide_rvw'])){
33
+ register_widget('RandomVideoSidebarWidget');
34
+ }
35
  }
36
 
37
+ //action to initiate widgets
38
+ add_action('widgets_init', 'load_video_sidebar_widgets');
 
 
 
 
 
 
 
 
 
 
39
  ?>
vsw_admin_settings.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin Settings
4
+ *
5
+ **/
6
+
7
+ //initiate menu
8
+ add_action('admin_menu', 'vsw_add_page');
9
+
10
+ // Add sub page to the Settings Menu
11
+ function vsw_add_page() {
12
+ add_options_page('Video Sidebar Widgets Settings', 'Video Sidebar Widgets','manage_options','video_sidebar_widget_settings', 'vsw_admin_page');
13
+ }
14
+
15
+ function vsw_admin_page(){
16
+ ?>
17
+ <div class="wrap">
18
+ <div class="icon32" id="icon-options-general"><br></div>
19
+ <h2>Video Sidebar Widgets Settings</h2>
20
+
21
+ <br/>
22
+
23
+ <form action="options.php" method="post">
24
+ <?php settings_fields('vsw_plugin_options'); ?>
25
+ <?php $options = get_option('vsw_plugin_options'); ?>
26
+
27
+ <p><span class="description" style="font-size:14px">By default, all components of this plugin will be loaded. However you can use this setting to remove components not used. Please check to remove.</span></p>
28
+
29
+ <div style="float:left;padding:5px;margin:10px 10px 10px 0px;text-align:center">
30
+ <img style='border:1px solid #eee;padding:5px;' src="<?php echo WP_PLUGIN_URL.'/video-sidebar-widgets/source_image/vsw.png'?>"/>
31
+ <br/>
32
+ <label>Video Sidebar Widget</label>
33
+ <?php
34
+ if($options['hide_vsw']) { $checked1 = ' checked="checked" '; }
35
+ echo "<input ".$checked1." id='vsw' name='vsw_plugin_options[hide_vsw]' type='checkbox' value='hide'/>";
36
+ ?>
37
+ </div>
38
+
39
+ <div style="float:left;padding:5px;margin:10px 10px 10px 0px;text-align:center">
40
+ <img style='border:1px solid #eee;padding:5px;' src="<?php echo WP_PLUGIN_URL.'/video-sidebar-widgets/source_image/rvw.png'?>"/>
41
+ <br/>
42
+ <label>Random Video Widget</label>
43
+ <?php
44
+ if($options['hide_rvw']) { $checked2 = ' checked="checked" '; }
45
+ echo "<input ".$checked2." id='rvw' name='vsw_plugin_options[hide_rvw]' type='checkbox' value='hide'/>";
46
+ ?>
47
+ </div>
48
+
49
+ <div style="float:left;padding:5px;margin:10px 10px 10px 0px;text-align:center">
50
+ <img style='border:1px solid #eee;padding:5px;' src="<?php echo WP_PLUGIN_URL.'/video-sidebar-widgets/source_image/tinybutton.png'?>"/>
51
+ <br/>
52
+ <label>TinyMCE Editor Button</label>
53
+ <?php
54
+ if($options['hide_tmb']) { $checked3 = ' checked="checked" '; }
55
+ echo "<input ".$checked3." id='tmb' name='vsw_plugin_options[hide_tmb]' type='checkbox' value='hide'/>";
56
+ ?>
57
+ </div>
58
+
59
+ <br/>
60
+
61
+ <div style="float:left;padding:5px;margin:10px 10px 10px 0px;clear:both">
62
+ <p>
63
+ <input name="Submit" type="submit" class="button-primary" value="<?php esc_attr_e('Save Changes'); ?>" />
64
+ </p>
65
+ <p class="description">If you ever need any modifications to the plugin, Please post it on <a href="http://wpquestions.com/affiliates/register/name/denzelchia" target="_blank">WP Questions.</a> Thanks!</p>
66
+ </div>
67
+ </form>
68
+ </div>
69
+ <?php
70
+ }
71
+
72
+ add_action('admin_init', 'vsw_register_options' );
73
+ // Register our settings. Add the settings section, and settings fields
74
+ function vsw_register_options(){
75
+ register_setting('vsw_plugin_options', 'vsw_plugin_options');
76
+ }
77
+ ?>
editor_plugin.js → vsw_tinymce/editor_plugin.js RENAMED
File without changes
vsw.gif → vsw_tinymce/vsw.gif RENAMED
File without changes
vsw_dialog.htm → vsw_tinymce/vsw_dialog.htm RENAMED
@@ -2,7 +2,7 @@
2
  "http://www.w3.org/TR/html4/loose.dtd">
3
  <head>
4
  <title>Video Sidebar Widgets (Extension) Insert Video ShortCode</title>
5
- <script type="text/javascript" src="../../../wp-includes/js/tinymce/tiny_mce_popup.js"></script>
6
  <script type="text/javascript" src="vsw_dialog.js"></script>
7
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
8
  <style type="text/css">
2
  "http://www.w3.org/TR/html4/loose.dtd">
3
  <head>
4
  <title>Video Sidebar Widgets (Extension) Insert Video ShortCode</title>
5
+ <script type="text/javascript" src="../../../../wp-includes/js/tinymce/tiny_mce_popup.js"></script>
6
  <script type="text/javascript" src="vsw_dialog.js"></script>
7
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
8
  <style type="text/css">
vsw_dialog.js → vsw_tinymce/vsw_dialog.js RENAMED
File without changes
vsw_tinymce/vsw_tinymce.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Tinymce Editor Button
4
+ *
5
+ **/
6
+
7
+ //add tinymce button to editor
8
+ function dd_vsw_addbuttons() {
9
+ //Stop if current user lacks permissions
10
+ if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') )
11
+ return;
12
+
13
+ // Add only in Rich Editor mode
14
+ if ( get_user_option('rich_editing') == 'true') {
15
+ add_filter("mce_external_plugins", "dd_vsw_tinymce_plugin"); // add plugin url to plugin url array.
16
+ add_filter('mce_buttons', 'dd_vsw_button'); //add button to first row.
17
+ }
18
+ }
19
+
20
+ // init process for button control
21
+ add_action('init', 'dd_vsw_addbuttons');
22
+
23
+ //push button
24
+ function dd_vsw_button($tiny_buttons) {
25
+ array_push($tiny_buttons, "vsw");
26
+ return $tiny_buttons;
27
+ }
28
+
29
+ // Load the TinyMCE plugin : editor_plugin.js (wp2.5)
30
+ function dd_vsw_tinymce_plugin($plugin_array) {
31
+
32
+ //check if defined WP_PLUGINS_URL
33
+ if (defined('WP_PLUGINS_URL')) {
34
+
35
+ $url_to_plugin = WP_PLUGINS_URL."/video-sidebar-widgets/vsw_tinymce/editor_plugin.js";
36
+
37
+ }else{
38
+ //if not assume it is default location.
39
+ $url_to_plugin = "../../../wp-content/plugins/video-sidebar-widgets/vsw_tinymce/editor_plugin.js";
40
+
41
+ }
42
+
43
+ //check option settings whether to load in TinyMCE button
44
+ $options = get_option('vsw_plugin_options');
45
+ if(empty($options['hide_tmb'])){
46
+ $plugin_array['vsw'] = $url_to_plugin; //add to tinymce plugins array
47
+ return $plugin_array;
48
+
49
+ }else{
50
+ return $plugin_array; // no addition to tinymce plugins array
51
+ }
52
+
53
+ }
54
+ ?>