Video Sidebar Widgets - Version 5.0

Version Description

  • Added Post Meta Video Widget (instructions within Widget)
Download this release

Release Info

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

Code changes from version 4.1 to 5.0

class-postmetavideowidget.php ADDED
@@ -0,0 +1,332 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Widget - Post Meta Video Widget
4
+ */
5
+
6
+ //Post Meta Video Widget Class to extend WP_Widget class
7
+ class PostMetaVideoWidget extends WP_Widget {
8
+
9
+ //function to set up widget in admin
10
+ function PostMetaVideoWidget() {
11
+
12
+ $widget_ops = array( 'classname' => 'postmetavideo',
13
+ 'description' => __('A Video Widget that is controlled by Post or Page custom field settings.', 'postmetavideo') );
14
+
15
+ $control_ops = array( 'width' => 200, 'height' => 350, 'id_base' => 'postmetavideo' );
16
+ $this->WP_Widget( 'postmetavideo', __('Post Meta Video Widget', 'postmetavideo'), $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
+ if(is_single()||is_page()):
26
+
27
+ //get post meta and output video
28
+ global $post;
29
+ $post_id = $post->ID;
30
+ $videosource = get_post_meta($post_id,'vsw_pmvw_video_source',true);
31
+ $videoid = get_post_meta($post_id,'vsw_pmvw_video_id',true);
32
+ $videowidth = get_post_meta($post_id,'vsw_pmvw_video_width',true);
33
+ $videoheight = get_post_meta($post_id,'vsw_pmvw_video_height',true);
34
+ $videocaption = get_post_meta($post_id,'vsw_pmvw_video_caption',true);
35
+ $autoplaysetting = get_post_meta($post_id,'vsw_pmvw_video_autoplay',true);
36
+
37
+ if(!empty($videoid)): // output only if video id is present!
38
+
39
+ $title = $instance['title'];
40
+
41
+ echo $before_widget;
42
+
43
+ // if user written title echo out
44
+ if ($title){
45
+ echo $before_title . $title . $after_title;
46
+ }
47
+
48
+ //function to show video in blog sidebar, please look for it in helper-functions.php
49
+ VSWShowVideo($videosource,$videoid,$autoplaysetting,$videowidth,$videoheight,'false','false');
50
+
51
+ if($videocaption){
52
+ echo "<p class=\"VideoCaption\">$videocaption</p>";
53
+ }
54
+
55
+ echo $after_widget;
56
+
57
+ endif; // !empty($videoid) check
58
+
59
+ endif; // is_single()||is_page() check
60
+
61
+ }//end of function widget
62
+
63
+
64
+
65
+ //function to update widget setting
66
+ function update( $new_instance, $old_instance ) {
67
+
68
+ $instance = $old_instance;
69
+ $instance['title'] = strip_tags( $new_instance['title'] );
70
+ return $instance;
71
+
72
+ }//end of function update
73
+
74
+
75
+ //function to create Widget Admin form
76
+ function form($instance) {
77
+
78
+ $instance = wp_parse_args( (array) $instance, array( 'title' => '') );
79
+
80
+ $instance['title'] = strip_tags( $instance['title'] );
81
+ ?>
82
+ <p>
83
+ <label for="<?php echo $this->get_field_id('title'); ?>">Widget Title:</label>
84
+ <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>"
85
+ type="text" value="<?php echo $instance['title']; ?>" />
86
+ </p>
87
+
88
+ <div class="description">
89
+ <p>
90
+ Please use only one widget per sidebar. If there is multiple sidebars per post/page, please use only one widget on one sidebar.
91
+ </p>
92
+ <p>
93
+ The video output by this widget, will only be shown on Posts or Pages.
94
+ </p>
95
+ <p>
96
+ The settings for this widget is in your <a href="<?php echo admin_url().'post-new.php#vsw_post_meta_video_widget_setting';?>">Post Editor</a> or <a href="<?php echo admin_url().'post-new.php?post_type=page#vsw_post_meta_video_widget_setting';?>">Page Editor</a>. Please look for "Post Meta Video Widget Settings". This Widget will output Video according to individual post meta setting (Custom Field Setting).
97
+ </p>
98
+ <p>If you are not using this widget, you can disable this component <a href="<?php echo admin_url().'options-general.php?page=video_sidebar_widget_settings';?>">here</a> by checking on it and save changes.
99
+ </p>
100
+ </div>
101
+ <p>
102
+ Thank you for reading this!
103
+ </p>
104
+
105
+ <?php
106
+
107
+ }//end of function form($instance)
108
+
109
+ }//end of Class
110
+
111
+
112
+
113
+ /*
114
+ *Post meta box on right side of post editor
115
+ */
116
+
117
+
118
+ // WP 3.0+
119
+ // add_action( 'add_meta_boxes', 'vsw_add_custom_box' );
120
+
121
+ $options = get_option('vsw_plugin_options'); // check whether to load post meta box.
122
+ if(empty($options['hide_pmvw'])){
123
+
124
+ // backwards compatible
125
+ add_action( 'admin_init', 'vsw_add_custom_box', 1);
126
+
127
+ /* Do something with the data entered */
128
+ add_action( 'save_post', 'vsw_save_postdata' );
129
+ }
130
+
131
+
132
+ /* Adds a box to the main column on the Post and Page edit screens */
133
+ function vsw_add_custom_box() {
134
+ add_meta_box(
135
+ 'vsw_post_meta_video_widget_setting',
136
+ __( 'Post Meta Video Widget Settings', 'vsw_textdomain' ),
137
+ 'vsw_inner_custom_box',
138
+ 'post',
139
+ 'side'
140
+ );
141
+ add_meta_box(
142
+ 'vsw_post_meta_video_widget_setting',
143
+ __( 'Post Meta Video Widget Settings', 'vsw_textdomain' ),
144
+ 'vsw_inner_custom_box',
145
+ 'page',
146
+ 'side'
147
+ );
148
+ }
149
+
150
+ /* Prints the box content */
151
+ function vsw_inner_custom_box(){
152
+
153
+ // Use nonce for verification
154
+ wp_nonce_field( plugin_basename( __FILE__ ), 'vsw_noncename' );
155
+ ?>
156
+
157
+ <div class="description" id="vsw_post_meta_description" style="display:none;">
158
+ <p>
159
+ This is the widgets setting form for Post Meta Video Widget, which is a component of Video Sidebar Widgets Plugin. You can find the widget <a href="<?php echo admin_url().'widgets.php';?>">here</a>.
160
+ </p>
161
+ <p>
162
+ The video output by this widget, will only be shown on Posts or Pages.
163
+ </p>
164
+ <p>If you are not using this widget, you can disable this component <a href="<?php echo admin_url().'options-general.php?page=video_sidebar_widget_settings';?>">here</a> by checking on it and save changes.
165
+ </p>
166
+ <p>
167
+ Thank you for reading this!
168
+ </p>
169
+ </div>
170
+ <div>
171
+ <p>
172
+ <a href="#" onclick="document.getElementById('vsw_post_meta_description').style.display='block';return false;">What are these settings for?</a>
173
+ </p>
174
+ </div>
175
+
176
+
177
+
178
+ <?php
179
+ //retrieve all post meta setting to fill the form.
180
+ global $post;
181
+ $post_id = $post->ID;
182
+ $vsw_pmvw_video_source = get_post_meta($post_id,'vsw_pmvw_video_source',true);
183
+ $vsw_pmvw_video_id = get_post_meta($post_id,'vsw_pmvw_video_id',true);
184
+ $vsw_pmvw_video_width = get_post_meta($post_id,'vsw_pmvw_video_width',true);
185
+ $vsw_pmvw_video_height = get_post_meta($post_id,'vsw_pmvw_video_height',true);
186
+ $vsw_pmvw_video_caption = get_post_meta($post_id,'vsw_pmvw_video_caption',true);
187
+ $vsw_pmvw_video_autoplay = get_post_meta($post_id,'vsw_pmvw_video_autoplay',true);
188
+ ?>
189
+
190
+ <p><u>Video Preview in fixed width and height</u></p>
191
+
192
+ <p>
193
+ <?php
194
+ VSWShowVideo($vsw_pmvw_video_source,$vsw_pmvw_video_id,$vsw_pmvw_video_autoplay,$vsw_pmvw_video_width,$vsw_pmvw_video_height,'true','false');
195
+ ?>
196
+ </p>
197
+
198
+
199
+ <p>
200
+ <label for="vsw_pmvw_video_source">Select Video Source:</label>
201
+ <select id="vsw_pmvw_video_source" name="vsw_pmvw_video_source" class="widefat" style="width:100%;">
202
+
203
+ <?php
204
+ $network = array('YouTube','Vimeo','MySpace','Veoh','Blip','WordPress','Viddler','DailyMotion','Revver','Metacafe','Tudou','Youku','cn6','Google');
205
+
206
+ foreach($network as $net){
207
+
208
+ echo "<option value='$net'";
209
+ if($vsw_pmvw_video_source == $net){
210
+ echo 'selected="selected"';
211
+ }
212
+ echo" >$net</option>";
213
+
214
+ }
215
+
216
+ ?>
217
+ </select>
218
+ </p>
219
+
220
+
221
+ <p>
222
+ <label for="vsw_pmvw_video_id">Video ID: </label>
223
+ <input class="widefat" id="vsw_pmvw_video_id" name="vsw_pmvw_video_id" type="text" value="<?php echo $vsw_pmvw_video_id; ?>" /></p>
224
+
225
+ <p>
226
+ <label for="vsw_pmvw_video_width">Video Width: </label>
227
+ <input class="widefat" id="vsw_pmvw_video_width" name="vsw_pmvw_video_width" type="text" value="<?php echo $vsw_pmvw_video_width; ?>" />
228
+ </p>
229
+
230
+ <p>
231
+ <label for="vsw_pmvw_video_height">Video Height: </label>
232
+ <input class="widefat" id="vsw_pmvw_video_height" name="vsw_pmvw_video_height" type="text" value="<?php echo $vsw_pmvw_video_height; ?>" />
233
+ </p>
234
+
235
+ <p>
236
+ <label for="vsw_pmvw_video_caption">Video Caption: </label>
237
+ <input class="widefat" id="vsw_pmvw_video_caption" name="vsw_pmvw_video_caption" type="text" value="<?php echo $vsw_pmvw_video_caption; ?>" />
238
+ </p>
239
+
240
+
241
+ <?php
242
+
243
+ // check whether autoplay feature supported by video network
244
+ if($vsw_pmvw_video_autoplay == '1'):
245
+ $source = $vsw_pmvw_video_source;
246
+ $msg = "<p class='description'>Sorry, auto play option not supported by ".$source."</p>";
247
+ switch ($source) {
248
+
249
+ case WordPress:
250
+ echo $msg;
251
+ break;
252
+
253
+ case Tudou:
254
+ echo $msg;
255
+ break;
256
+
257
+ case Youku:
258
+ echo $msg;
259
+ break;
260
+
261
+ case Blip:
262
+ echo "<p class='description'>Sorry, auto play option for BlipTv was removed as it is causing error in Internet Explorer</p>";
263
+ break;
264
+
265
+ case cn6:
266
+ echo "<p class='description'>Sorry, auto play option not supported by 6.cn</p>";
267
+ break;
268
+ }
269
+
270
+ endif;
271
+ ?>
272
+
273
+ <p>
274
+ <label for="vsw_pmvw_video_autoplay">Auto Play:</label>
275
+ <select id="vsw_pmvw_video_autoplay"
276
+ name="vsw_pmvw_video_autoplay" class="widefat" style="width:100%;">';
277
+ <option value='0' <?php if($vsw_pmvw_video_autoplay == '0'){echo 'selected="selected"';}?>>No</option>
278
+ <option value='1' <?php if($vsw_pmvw_video_autoplay == '1'){echo 'selected="selected"';}?>>Yes</option>
279
+ </select>
280
+ </p>
281
+
282
+
283
+ <?php
284
+ }
285
+
286
+ /* When the post is saved, saves our custom data */
287
+ function vsw_save_postdata( $post_id ){
288
+ // verify if this is an auto save routine.
289
+ // If it is our form has not been submitted, so we dont want to do anything
290
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
291
+ return;
292
+
293
+ // verify this came from the our screen and with proper authorization,
294
+ // because save_post can be triggered at other times
295
+
296
+ if ( !wp_verify_nonce( $_POST['vsw_noncename'], plugin_basename( __FILE__ ) ) )
297
+ return;
298
+
299
+
300
+ // Check permissions
301
+ if ( 'page' == $_POST['post_type'] )
302
+ {
303
+ if ( !current_user_can( 'edit_page', $post_id ) )
304
+ return;
305
+ }
306
+ else
307
+ {
308
+ if ( !current_user_can( 'edit_post', $post_id ) )
309
+ return;
310
+ }
311
+
312
+ // OK, we're authenticated: we need to find and save the data
313
+
314
+ $data1 = $_POST['vsw_pmvw_video_source'];
315
+ $data2 = $_POST['vsw_pmvw_video_id'];
316
+ $data3 = $_POST['vsw_pmvw_video_width'];
317
+ $data4 = $_POST['vsw_pmvw_video_height'];
318
+ $data5 = $_POST['vsw_pmvw_video_caption'];
319
+ $data6 = $_POST['vsw_pmvw_video_autoplay'];
320
+
321
+
322
+ global $post;
323
+ $post_id = $post->ID;
324
+ update_post_meta($post_id,'vsw_pmvw_video_source',$data1);
325
+ update_post_meta($post_id,'vsw_pmvw_video_id',$data2);
326
+ update_post_meta($post_id,'vsw_pmvw_video_width',$data3);
327
+ update_post_meta($post_id,'vsw_pmvw_video_height',$data4);
328
+ update_post_meta($post_id,'vsw_pmvw_video_caption',$data5);
329
+ update_post_meta($post_id,'vsw_pmvw_video_autoplay',$data6);
330
+
331
+ }
332
+ ?>
class-randomvideosidebarwidget.php CHANGED
@@ -140,7 +140,7 @@ extract( $args );
140
  $rv_flashvar = "<param name='flashvars' value='$Embed_id'>";
141
  $rv_flashvar2 = 'flashvars="guid='.$Embed_id.'"';
142
  $rv_cap = $Embed_cap;
143
- break;
144
 
145
  case Viddler:
146
  $rv_value = "http://www.viddler.com/player/$Embed_id";
140
  $rv_flashvar = "<param name='flashvars' value='$Embed_id'>";
141
  $rv_flashvar2 = 'flashvars="guid='.$Embed_id.'"';
142
  $rv_cap = $Embed_cap;
143
+ break;
144
 
145
  case Viddler:
146
  $rv_value = "http://www.viddler.com/player/$Embed_id";
readme.txt CHANGED
@@ -4,8 +4,8 @@ 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.1.1
8
- Stable tag:4.1
9
 
10
  == Description ==
11
 
@@ -14,6 +14,10 @@ Stable tag:4.1
14
 
15
  == Changelog ==
16
 
 
 
 
 
17
  = 4.1 =
18
 
19
  *Fixed WordPress Video in random video widget (Sorry forgotten about this!)
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.2
8
+ Stable tag:5.0
9
 
10
  == Description ==
11
 
14
 
15
  == Changelog ==
16
 
17
+ = 5.0 =
18
+
19
+ * Added Post Meta Video Widget (instructions within Widget)
20
+
21
  = 4.1 =
22
 
23
  *Fixed WordPress Video in random video widget (Sorry forgotten about this!)
source_image/pmvw.png ADDED
Binary file
video-sidebar-widgets.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Video Sidebar Widgets
4
  Plugin URI: http://denzeldesigns.com/wordpress-plugins/video-sidebar-widgets/
5
- Version: 4.1
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/
@@ -23,6 +23,9 @@ require_once(dirname(__FILE__) . "/class-videosidebarwidget.php");
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');
@@ -31,6 +34,9 @@ function load_video_sidebar_widgets(){
31
  }
32
  if(empty($options['hide_rvw'])){
33
  register_widget('RandomVideoSidebarWidget');
 
 
 
34
  }
35
  }
36
 
2
  /*
3
  Plugin Name: Video Sidebar Widgets
4
  Plugin URI: http://denzeldesigns.com/wordpress-plugins/video-sidebar-widgets/
5
+ Version: 5.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/
23
  // Random Video Widget
24
  require_once(dirname(__FILE__) . "/class-randomvideosidebarwidget.php");
25
 
26
+ // Post Meta Video Widget
27
+ require_once(dirname(__FILE__) . "/class-postmetavideowidget.php");
28
+
29
  //function to register Video Sidebar Widget and Random Video Sidebar Widget
30
  function load_video_sidebar_widgets(){
31
  $options = get_option('vsw_plugin_options');
34
  }
35
  if(empty($options['hide_rvw'])){
36
  register_widget('RandomVideoSidebarWidget');
37
+ }
38
+ if(empty($options['hide_pmvw'])){
39
+ register_widget('PostMetaVideoWidget');
40
  }
41
  }
42
 
vsw_admin_settings.php CHANGED
@@ -56,6 +56,18 @@ function vsw_admin_page(){
56
  ?>
57
  </div>
58
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  <br/>
60
 
61
  <div style="float:left;padding:5px;margin:10px 10px 10px 0px;clear:both">
56
  ?>
57
  </div>
58
 
59
+
60
+ <div style="float:left;padding:5px;margin:10px 10px 10px 0px;text-align:center">
61
+ <img style='border:1px solid #eee;padding:5px;' src="<?php echo WP_PLUGIN_URL.'/video-sidebar-widgets/source_image/pmvw.png'?>"/>
62
+ <br/>
63
+ <label>Post Meta Video Widget</label>
64
+ <?php
65
+ if($options['hide_pmvw']) { $checked4 = ' checked="checked" '; }
66
+ echo "<input ".$checked4." id='tmb' name='vsw_plugin_options[hide_pmvw]' type='checkbox' value='hide'/>";
67
+ ?>
68
+ </div>
69
+
70
+
71
  <br/>
72
 
73
  <div style="float:left;padding:5px;margin:10px 10px 10px 0px;clear:both">