Changeset 485261
- Timestamp:
- 01/05/2012 07:37:14 PM (14 years ago)
- Location:
- youtubenails
- Files:
-
- 4 edited
-
branches/readme.txt (modified) (4 diffs)
-
branches/youtubenails.php (modified) (13 diffs)
-
trunk/readme.txt (modified) (4 diffs)
-
trunk/youtubenails.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
youtubenails/branches/readme.txt
r355277 r485261 4 4 Tags: youtube,thumbnails,video 5 5 Requires at least: 3.0.3 6 Tested up to: 3. 0.37 Stable tag: 2.0.06 Tested up to: 3.2.1 7 Stable tag: 3.0.0 8 8 9 9 == Description == 10 10 11 Create a dynamic gallery widget(works as shortcode too, if desired), with thumbnails of each post with youtube videos displayed on the content linked to the post permalink. It checks all you video posts, but you can filter them by category and choose the number of posts.11 Create a dynamic gallery multiple widget(works as shortcode too), with thumbnails of each post with youtube/vimeo(beta) videos displayed on the content linked to the post single. Checks all you video posts, but you can filter them by category and choose the number of posts. 12 12 13 13 Based on … … 51 51 7. The table id for the result table wp_ytbnstb; 52 52 53 To work as short code 53 To work as short code, call 54 [ytbn nop="2" ln="1" catg="" tbsz="1" cpad="3" cpin="3"] 54 55 55 call it on phpyoutubenails_show(8,1,'',2,3,3);56 or call it on php as function youtubenails_show(8,1,'',2,3,3); 56 57 57 58 where the parameters are … … 76 77 77 78 == Changelog == 79 3.0.0 80 Supports multiple widgets and shortcodes; 81 Vimeo supported(beta feature); 82 78 83 2.0.0 79 84 … … 90 95 91 96 <!-- 97 http://www.youtube.com/watch?v=gNwuES4lMeQ 98 92 99 <iframe title="YouTube video player" class="youtube-player" type="text/html" width="480" height="390" src="http://www.youtube.com/embed/yXYW4c-FndI" frameborder="0" allowFullScreen></iframe> 93 100 -
youtubenails/branches/youtubenails.php
r354590 r485261 4 4 Plugin URI: http://youtubenails.sourceforge.net/ 5 5 Description:Create a dynamic gallery of thumbnails of each post with youtube videos displayed on the content linked to the post permalink 6 Version: 2.0.06 Version: 3.0.0 7 7 Author: Alvaro Neto 8 8 Author URI: http://wpworks.wordpress.com/ … … 26 26 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 27 27 */ 28 // 29 add_shortcode('ytbn','ytbn_short'); 30 // 31 function ytbn_short($atts, $content = null){ 32 extract(shortcode_atts(array( 33 'ptype' => 'post', 34 'nop' => '8', 35 'ln' => 3, 36 'catg' => '', 37 'tbsz' => 2, 38 'cpad' => 3, 39 'cpin' =>3, 40 'ech' => false 41 ), $atts)); 42 ob_start(); 43 $ytbnres=youtubenails_show($nop,$ln,$catg,$tbsz,$cpad,$cpin,$ech); 44 echo $ytbnres; 45 $ytbn_string = ob_get_contents(); 46 ob_end_clean(); 47 return $ytbn_string; 48 } 49 // 50 /** 51 * Add FAQ and support information 52 */ 53 add_filter('plugin_row_meta', 'wp_ytbn_plugin_links', 10, 2); 54 function wp_ytbn_plugin_links ($links, $file) 55 { 56 if ($file == plugin_basename(__FILE__)) { 57 $links[] = '<a href="http://www.wpworking.com/">' . __('Donate', 'wp_ytbn') . '</a>'; 58 } 59 return $links; 60 } 61 // 28 62 function partrat($par,$def) 29 63 { … … 36 70 return $par; 37 71 } 72 function getVimeoInfo($id, $info = 'thumbnail_medium') { 73 if (!function_exists('curl_init')) die('CURL is not installed, impossible to display vimeo, sorry!'); 74 $ch = curl_init(); 75 curl_setopt($ch, CURLOPT_URL, "vimeo.com/api/v2/video/$id.php"); 76 curl_setopt($ch, CURLOPT_HEADER, 0); 77 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 78 curl_setopt($ch, CURLOPT_TIMEOUT, 10); 79 $output = unserialize(curl_exec($ch)); 80 $output = $output[0][$info]; 81 curl_close($ch); 82 return $output; 83 } 38 84 39 function youtubenails_show($nop=8,$ln=3,$catg='',$tbsz=2,$cpad=3,$cpin=3 )85 function youtubenails_show($nop=8,$ln=3,$catg='',$tbsz=2,$cpad=3,$cpin=3,$ech=true) 40 86 { 41 87 $nop = partrat($nop,8); … … 45 91 $cpad = partrat($cpad,3); 46 92 $cpin = partrat($cpin,3); 93 $ech = partrat($ech,true); 47 94 48 95 //echo "cpad:".$cpad."<br>"; … … 60 107 } 61 108 62 if (have_posts()) :109 //if (have_posts()) : 63 110 // Gets the post's content 64 111 global $post; … … 67 114 $myposts = get_posts("numberposts=".$nop."&category_name='".$catg."'"); 68 115 //get_posts('category_name='.$catg); 116 query_posts("numberposts=".$nop."&category_name='".$catg."'"); 69 117 else: 70 118 $myposts = get_posts("numberposts=".$nop); 119 query_posts("numberposts=".$nop); 71 120 //get_posts(); 72 121 endif; … … 76 125 if($lmtcnt>0): 77 126 $tbhtml = "<table cellpadding='".$cpad."' cellspacing='".$cpin."' border='0' id='wp_ytbnstb'>"; 78 foreach($myposts as $post) :79 $post_id = $post->ID;127 while (have_posts()) : the_post(); 128 $post_id = get_the_ID(); 80 129 $post_array = get_post($post_id); 81 130 //$markup = get_the_content(); … … 102 151 // Checks for a standard YouTube embed 103 152 preg_match('#<object[^>]+>.+?http://www.youtube.com/v/([A-Za-z0-9\-_]+).+?</object>#s', $markup, $matches); 104 105 106 153 107 154 // Checks for YouTube iframe … … 140 187 //echo "teste6"; 141 188 $new_thumbnail = $youtube_thumbnail; 142 } else { 189 } 190 else { 143 191 //echo "teste7"; 144 192 $ch = curl_init($youtube_thumbnail); … … 154 202 } 155 203 } 156 //echo $new_thumbnail; 157 $rwcnt = $rwcnt + 1; 204 // Vimeo 205 if($new_thumbnail==null) { 206 207 // Standard embed code 208 preg_match('#<object[^>]+>.+?http://vimeo.com/moogaloop.swf\?clip_id=([A-Za-z0-9\-_]+)&.+?</object>#s', $markup, $matches); 209 210 // Find Vimeo embedded with iframe code 211 if(!isset($matches[1])) { 212 preg_match('#http://player.vimeo.com/video/([0-9]+)#s', $markup, $matches); 213 } 214 215 // If we still haven't found anything, check for Vimeo embedded with JR_embed 216 if(!isset($matches[1])) { 217 preg_match('#\[vimeo id=([A-Za-z0-9\-_]+)]#s', $markup, $matches); 218 } 219 220 // If we still haven't found anything, check for Vimeo URL 221 if(!isset($matches[1])) { 222 preg_match('#http://w?w?w?.?vimeo.com/([A-Za-z0-9\-_]+)#s', $markup, $matches); 223 } 224 225 // If we still haven't found anything, check for Vimeo URL 226 if(!isset($matches[1])) { 227 preg_match('#http://?vimeo.com/([A-Za-z0-9\-_]+)#s', $markup, $matches); 228 } 229 230 // If we still haven't found anything, check for Vimeo shortcode 231 if(!isset($matches[1])) { 232 preg_match('#\[vimeo clip_id="([A-Za-z0-9\-_]+)"[^>]*]#s', $markup, $matches); 233 } 234 if(!isset($matches[1])) { 235 preg_match('#\[vimeo video_id="([A-Za-z0-9\-_]+)"[^>]*]#s', $markup, $matches); 236 } 237 238 // Now if we've found a Vimeo ID, let's set the thumbnail URL 239 if(isset($matches[1])) { 240 $vimeo_thumbnail = getVimeoInfo($matches[1], $info = 'thumbnail_small'); 241 if(isset($vimeo_thumbnail)) { 242 $new_thumbnail = $vimeo_thumbnail; 243 } 244 } 245 } 246 247 $rwcnt = $rwcnt + 1; 158 248 if($new_thumbnail!=null): 159 249 //echo "teste8"; … … 167 257 } 168 258 endif; 169 end foreach;259 endwhile; 170 260 $tbhtml .= "</table>"; 171 261 echo $tbhtml; 172 endif;262 //endif; 173 263 endif; 174 264 } … … 208 298 'tbsz' => '', 209 299 'cpad' => '', 210 'cpin ' => ''300 'cpin' => '' 211 301 ); 212 302 } … … 261 351 function youtubenails_init() 262 352 { 263 register_sidebar_widget(__('YouTubeNails'), 'widget_youtubenails_show'); 264 register_widget_control( 'YouTubeNails', 'youtubenails_control', 400, 400 ); 265 } 266 add_action("plugins_loaded", "youtubenails_init"); 353 //register_sidebar_widget(__('YouTubeNails'), 'widget_youtubenails_show'); 354 //register_widget_control( 'YouTubeNails', 'youtubenails_control', 400, 400 ); 355 } 356 //add_action("plugins_loaded", "youtubenails_init"); 357 add_action('widgets_init', 'ytbn_register_widgets'); 358 function ytbn_register_widgets(){ 359 // curl need to be installed 360 register_widget('YTBN_Widget'); 361 } 362 // 363 class YTBN_Widget extends WP_Widget { 364 function YTBN_Widget() { 365 /* Widget settings. */ 366 $widget_ops = array( 'classname' => 'ytbn', 'description' => 'This is the YouTubeNails Plugin Widget.' ); 367 /* Widget control settings. */ 368 $control_ops = array( 'width' => 700, 'height' => 300, 'id_base' => 'ytbn-widget' ); 369 /* Create the widget. */ 370 $this->WP_Widget( 'ytbn-widget', 'YTBN Widget', $widget_ops, $control_ops ); 371 } 372 function widget( $args, $instance ) { 373 extract( $args ); 374 //$instance = get_option("widget_getPostListThumbs"); 375 if (!is_array( $options )) 376 { 377 $options = array( 378 'nop' => '', 379 'ln' => '', 380 'catg' => '', 381 'tbsz' => '', 382 'cpad' => '', 383 'cpin ' => '' 384 ); 385 } 386 /*echo $before_widget; 387 echo $before_title; 388 echo $options['title']; 389 echo $after_title; 390 echo $after_widget;*/ 391 //Our Widget Content 392 youtubenails_show($instance['nop'],$instance['ln'],$instance['catg'],$instance['tbsz'],$instance['cpad'],$instance['cpin']); 393 } 394 function update( $new_instance, $old_instance ) { 395 $instance = $old_instance; 396 /* Strip tags (if needed) and update the widget settings. */ 397 $instance['nop'] = $new_instance['nop']; 398 $instance['ln'] = $new_instance['ln']; 399 $instance['catg'] = $new_instance['catg']; 400 $instance['tbsz'] = $new_instance['tbsz']; 401 $instance['cpad'] = $new_instance['cpad']; 402 $instance['cpin'] = $new_instance['cpin']; 403 return $instance; 404 } 405 function form( $instance ) { 406 /* Set up some default widget settings. */ 407 $defaults = array( 408 409 'ptype' => 'post', 410 'nop' => '8', 411 'ln' => 3, 412 'catg' => '', 413 'tbsz' => 2, 414 'cpad' => 3, 415 'cpin' =>3, 416 'ech' => false 417 ); 418 $instance = wp_parse_args( (array) $instance, $defaults ); 267 419 ?> 420 <p> 421 <label for="<?php echo $this->get_field_id( 'nop' ); ?>">Number of Posts(default is 8): </label><br /> 422 <input type="text" id="<?php echo $this->get_field_id( 'nop' ); ?>" name="<?php echo $this->get_field_name( 'nop' ); ?>" value="<?php echo $instance['nop'];?>" size="4"/> 423 <br /> 424 <label for="<?php echo $this->get_field_id( 'ln' ); ?>">Number of columns on each row(default is 3): </label><br /> 425 <input type="text" id="<?php echo $this->get_field_id( 'ln' ); ?>" name="<?php echo $this->get_field_name( 'ln' ); ?>" value="<?php echo $instance['ln'];?>" size="4"/> 426 <br /> 427 <label for="<?php echo $this->get_field_id( 'catg' ); ?>">A specific category of posts(default is all, leave it blank): </label><br /> 428 <input type="text" id="<?php echo $this->get_field_id( 'catg' ); ?>" name="<?php echo $this->get_field_name( 'catg' ); ?>" value="<?php echo $instance['catg'];?>" size="20"/> 429 <br /> 430 <label for="<?php echo $this->get_field_id( 'tbsz' ); ?>">The thumbnail type based on YouTube API(default is 2, see the list below): </label><br /> 431 <input type="text" id="<?php echo $this->get_field_id( 'tbsz' ); ?>" name="<?php echo $this->get_field_name( 'tbsz' ); ?>" value="<?php echo $instance['tbsz'];?>" size="4"/> 432 <br /><label style="font-size:9px">YouTube API sizes and types:<br /> 0 = big 480 x 360<br /> 433 1 = small 120 x 90 different from 2 & 3<br /> 434 2 = small 120 x 90 different from 1 & 3<br /> 435 3 = small 120 x 90 different from 2 & 1</label><br /> 436 <br /> 437 <label for="<?php echo $this->get_field_id( 'cpad' ); ?>">The result table cellpadding(default is 3): </label><br /> 438 <input type="text" id="<?php echo $this->get_field_id( 'cpad' ); ?>" name="<?php echo $this->get_field_name( 'cpad' ); ?>" value="<?php echo $instance['cpad'];?>" size="4"/> 439 <br /> 440 <label for="<?php echo $this->get_field_id( 'cpin' ); ?>">The result table cellspacing(default is 3): </label><br /> 441 <input type="text" id="<?php echo $this->get_field_id( 'cpin' ); ?>" name="<?php echo $this->get_field_name( 'cpin' ); ?>" value="<?php echo $instance['cpin'];?>" size="4"/> 442 <br /> 443 <label>The result list will be a table, that uses the css class 'wp_ytbnstb', so you can play with the table properties, and the inside elements.</label><br /> 444 <input type="hidden" id="youtubenails-Submit" name="youtubenails-Submit" value="1" /> 445 </p> 446 <?php 447 } 448 } 449 ?> -
youtubenails/trunk/readme.txt
r355277 r485261 4 4 Tags: youtube,thumbnails,video 5 5 Requires at least: 3.0.3 6 Tested up to: 3. 0.37 Stable tag: 2.0.06 Tested up to: 3.2.1 7 Stable tag: 3.0.0 8 8 9 9 == Description == 10 10 11 Create a dynamic gallery widget(works as shortcode too, if desired), with thumbnails of each post with youtube videos displayed on the content linked to the post permalink. It checks all you video posts, but you can filter them by category and choose the number of posts.11 Create a dynamic gallery multiple widget(works as shortcode too), with thumbnails of each post with youtube/vimeo(beta) videos displayed on the content linked to the post single. Checks all you video posts, but you can filter them by category and choose the number of posts. 12 12 13 13 Based on … … 51 51 7. The table id for the result table wp_ytbnstb; 52 52 53 To work as short code 53 To work as short code, call 54 [ytbn nop="2" ln="1" catg="" tbsz="1" cpad="3" cpin="3"] 54 55 55 call it on phpyoutubenails_show(8,1,'',2,3,3);56 or call it on php as function youtubenails_show(8,1,'',2,3,3); 56 57 57 58 where the parameters are … … 76 77 77 78 == Changelog == 79 3.0.0 80 Supports multiple widgets and shortcodes; 81 Vimeo supported(beta feature); 82 78 83 2.0.0 79 84 … … 90 95 91 96 <!-- 97 http://www.youtube.com/watch?v=gNwuES4lMeQ 98 92 99 <iframe title="YouTube video player" class="youtube-player" type="text/html" width="480" height="390" src="http://www.youtube.com/embed/yXYW4c-FndI" frameborder="0" allowFullScreen></iframe> 93 100 -
youtubenails/trunk/youtubenails.php
r354590 r485261 4 4 Plugin URI: http://youtubenails.sourceforge.net/ 5 5 Description:Create a dynamic gallery of thumbnails of each post with youtube videos displayed on the content linked to the post permalink 6 Version: 2.0.06 Version: 3.0.0 7 7 Author: Alvaro Neto 8 8 Author URI: http://wpworks.wordpress.com/ … … 26 26 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 27 27 */ 28 // 29 add_shortcode('ytbn','ytbn_short'); 30 // 31 function ytbn_short($atts, $content = null){ 32 extract(shortcode_atts(array( 33 'ptype' => 'post', 34 'nop' => '8', 35 'ln' => 3, 36 'catg' => '', 37 'tbsz' => 2, 38 'cpad' => 3, 39 'cpin' =>3, 40 'ech' => false 41 ), $atts)); 42 ob_start(); 43 $ytbnres=youtubenails_show($nop,$ln,$catg,$tbsz,$cpad,$cpin,$ech); 44 echo $ytbnres; 45 $ytbn_string = ob_get_contents(); 46 ob_end_clean(); 47 return $ytbn_string; 48 } 49 // 50 /** 51 * Add FAQ and support information 52 */ 53 add_filter('plugin_row_meta', 'wp_ytbn_plugin_links', 10, 2); 54 function wp_ytbn_plugin_links ($links, $file) 55 { 56 if ($file == plugin_basename(__FILE__)) { 57 $links[] = '<a href="http://www.wpworking.com/">' . __('Donate', 'wp_ytbn') . '</a>'; 58 } 59 return $links; 60 } 61 // 28 62 function partrat($par,$def) 29 63 { … … 36 70 return $par; 37 71 } 72 function getVimeoInfo($id, $info = 'thumbnail_medium') { 73 if (!function_exists('curl_init')) die('CURL is not installed, impossible to display vimeo, sorry!'); 74 $ch = curl_init(); 75 curl_setopt($ch, CURLOPT_URL, "vimeo.com/api/v2/video/$id.php"); 76 curl_setopt($ch, CURLOPT_HEADER, 0); 77 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 78 curl_setopt($ch, CURLOPT_TIMEOUT, 10); 79 $output = unserialize(curl_exec($ch)); 80 $output = $output[0][$info]; 81 curl_close($ch); 82 return $output; 83 } 38 84 39 function youtubenails_show($nop=8,$ln=3,$catg='',$tbsz=2,$cpad=3,$cpin=3 )85 function youtubenails_show($nop=8,$ln=3,$catg='',$tbsz=2,$cpad=3,$cpin=3,$ech=true) 40 86 { 41 87 $nop = partrat($nop,8); … … 45 91 $cpad = partrat($cpad,3); 46 92 $cpin = partrat($cpin,3); 93 $ech = partrat($ech,true); 47 94 48 95 //echo "cpad:".$cpad."<br>"; … … 60 107 } 61 108 62 if (have_posts()) :109 //if (have_posts()) : 63 110 // Gets the post's content 64 111 global $post; … … 67 114 $myposts = get_posts("numberposts=".$nop."&category_name='".$catg."'"); 68 115 //get_posts('category_name='.$catg); 116 query_posts("numberposts=".$nop."&category_name='".$catg."'"); 69 117 else: 70 118 $myposts = get_posts("numberposts=".$nop); 119 query_posts("numberposts=".$nop); 71 120 //get_posts(); 72 121 endif; … … 76 125 if($lmtcnt>0): 77 126 $tbhtml = "<table cellpadding='".$cpad."' cellspacing='".$cpin."' border='0' id='wp_ytbnstb'>"; 78 foreach($myposts as $post) :79 $post_id = $post->ID;127 while (have_posts()) : the_post(); 128 $post_id = get_the_ID(); 80 129 $post_array = get_post($post_id); 81 130 //$markup = get_the_content(); … … 102 151 // Checks for a standard YouTube embed 103 152 preg_match('#<object[^>]+>.+?http://www.youtube.com/v/([A-Za-z0-9\-_]+).+?</object>#s', $markup, $matches); 104 105 106 153 107 154 // Checks for YouTube iframe … … 140 187 //echo "teste6"; 141 188 $new_thumbnail = $youtube_thumbnail; 142 } else { 189 } 190 else { 143 191 //echo "teste7"; 144 192 $ch = curl_init($youtube_thumbnail); … … 154 202 } 155 203 } 156 //echo $new_thumbnail; 157 $rwcnt = $rwcnt + 1; 204 // Vimeo 205 if($new_thumbnail==null) { 206 207 // Standard embed code 208 preg_match('#<object[^>]+>.+?http://vimeo.com/moogaloop.swf\?clip_id=([A-Za-z0-9\-_]+)&.+?</object>#s', $markup, $matches); 209 210 // Find Vimeo embedded with iframe code 211 if(!isset($matches[1])) { 212 preg_match('#http://player.vimeo.com/video/([0-9]+)#s', $markup, $matches); 213 } 214 215 // If we still haven't found anything, check for Vimeo embedded with JR_embed 216 if(!isset($matches[1])) { 217 preg_match('#\[vimeo id=([A-Za-z0-9\-_]+)]#s', $markup, $matches); 218 } 219 220 // If we still haven't found anything, check for Vimeo URL 221 if(!isset($matches[1])) { 222 preg_match('#http://w?w?w?.?vimeo.com/([A-Za-z0-9\-_]+)#s', $markup, $matches); 223 } 224 225 // If we still haven't found anything, check for Vimeo URL 226 if(!isset($matches[1])) { 227 preg_match('#http://?vimeo.com/([A-Za-z0-9\-_]+)#s', $markup, $matches); 228 } 229 230 // If we still haven't found anything, check for Vimeo shortcode 231 if(!isset($matches[1])) { 232 preg_match('#\[vimeo clip_id="([A-Za-z0-9\-_]+)"[^>]*]#s', $markup, $matches); 233 } 234 if(!isset($matches[1])) { 235 preg_match('#\[vimeo video_id="([A-Za-z0-9\-_]+)"[^>]*]#s', $markup, $matches); 236 } 237 238 // Now if we've found a Vimeo ID, let's set the thumbnail URL 239 if(isset($matches[1])) { 240 $vimeo_thumbnail = getVimeoInfo($matches[1], $info = 'thumbnail_small'); 241 if(isset($vimeo_thumbnail)) { 242 $new_thumbnail = $vimeo_thumbnail; 243 } 244 } 245 } 246 247 $rwcnt = $rwcnt + 1; 158 248 if($new_thumbnail!=null): 159 249 //echo "teste8"; … … 167 257 } 168 258 endif; 169 end foreach;259 endwhile; 170 260 $tbhtml .= "</table>"; 171 261 echo $tbhtml; 172 endif;262 //endif; 173 263 endif; 174 264 } … … 208 298 'tbsz' => '', 209 299 'cpad' => '', 210 'cpin ' => ''300 'cpin' => '' 211 301 ); 212 302 } … … 261 351 function youtubenails_init() 262 352 { 263 register_sidebar_widget(__('YouTubeNails'), 'widget_youtubenails_show'); 264 register_widget_control( 'YouTubeNails', 'youtubenails_control', 400, 400 ); 265 } 266 add_action("plugins_loaded", "youtubenails_init"); 353 //register_sidebar_widget(__('YouTubeNails'), 'widget_youtubenails_show'); 354 //register_widget_control( 'YouTubeNails', 'youtubenails_control', 400, 400 ); 355 } 356 //add_action("plugins_loaded", "youtubenails_init"); 357 add_action('widgets_init', 'ytbn_register_widgets'); 358 function ytbn_register_widgets(){ 359 // curl need to be installed 360 register_widget('YTBN_Widget'); 361 } 362 // 363 class YTBN_Widget extends WP_Widget { 364 function YTBN_Widget() { 365 /* Widget settings. */ 366 $widget_ops = array( 'classname' => 'ytbn', 'description' => 'This is the YouTubeNails Plugin Widget.' ); 367 /* Widget control settings. */ 368 $control_ops = array( 'width' => 700, 'height' => 300, 'id_base' => 'ytbn-widget' ); 369 /* Create the widget. */ 370 $this->WP_Widget( 'ytbn-widget', 'YTBN Widget', $widget_ops, $control_ops ); 371 } 372 function widget( $args, $instance ) { 373 extract( $args ); 374 //$instance = get_option("widget_getPostListThumbs"); 375 if (!is_array( $options )) 376 { 377 $options = array( 378 'nop' => '', 379 'ln' => '', 380 'catg' => '', 381 'tbsz' => '', 382 'cpad' => '', 383 'cpin ' => '' 384 ); 385 } 386 /*echo $before_widget; 387 echo $before_title; 388 echo $options['title']; 389 echo $after_title; 390 echo $after_widget;*/ 391 //Our Widget Content 392 youtubenails_show($instance['nop'],$instance['ln'],$instance['catg'],$instance['tbsz'],$instance['cpad'],$instance['cpin']); 393 } 394 function update( $new_instance, $old_instance ) { 395 $instance = $old_instance; 396 /* Strip tags (if needed) and update the widget settings. */ 397 $instance['nop'] = $new_instance['nop']; 398 $instance['ln'] = $new_instance['ln']; 399 $instance['catg'] = $new_instance['catg']; 400 $instance['tbsz'] = $new_instance['tbsz']; 401 $instance['cpad'] = $new_instance['cpad']; 402 $instance['cpin'] = $new_instance['cpin']; 403 return $instance; 404 } 405 function form( $instance ) { 406 /* Set up some default widget settings. */ 407 $defaults = array( 408 409 'ptype' => 'post', 410 'nop' => '8', 411 'ln' => 3, 412 'catg' => '', 413 'tbsz' => 2, 414 'cpad' => 3, 415 'cpin' =>3, 416 'ech' => false 417 ); 418 $instance = wp_parse_args( (array) $instance, $defaults ); 267 419 ?> 420 <p> 421 <label for="<?php echo $this->get_field_id( 'nop' ); ?>">Number of Posts(default is 8): </label><br /> 422 <input type="text" id="<?php echo $this->get_field_id( 'nop' ); ?>" name="<?php echo $this->get_field_name( 'nop' ); ?>" value="<?php echo $instance['nop'];?>" size="4"/> 423 <br /> 424 <label for="<?php echo $this->get_field_id( 'ln' ); ?>">Number of columns on each row(default is 3): </label><br /> 425 <input type="text" id="<?php echo $this->get_field_id( 'ln' ); ?>" name="<?php echo $this->get_field_name( 'ln' ); ?>" value="<?php echo $instance['ln'];?>" size="4"/> 426 <br /> 427 <label for="<?php echo $this->get_field_id( 'catg' ); ?>">A specific category of posts(default is all, leave it blank): </label><br /> 428 <input type="text" id="<?php echo $this->get_field_id( 'catg' ); ?>" name="<?php echo $this->get_field_name( 'catg' ); ?>" value="<?php echo $instance['catg'];?>" size="20"/> 429 <br /> 430 <label for="<?php echo $this->get_field_id( 'tbsz' ); ?>">The thumbnail type based on YouTube API(default is 2, see the list below): </label><br /> 431 <input type="text" id="<?php echo $this->get_field_id( 'tbsz' ); ?>" name="<?php echo $this->get_field_name( 'tbsz' ); ?>" value="<?php echo $instance['tbsz'];?>" size="4"/> 432 <br /><label style="font-size:9px">YouTube API sizes and types:<br /> 0 = big 480 x 360<br /> 433 1 = small 120 x 90 different from 2 & 3<br /> 434 2 = small 120 x 90 different from 1 & 3<br /> 435 3 = small 120 x 90 different from 2 & 1</label><br /> 436 <br /> 437 <label for="<?php echo $this->get_field_id( 'cpad' ); ?>">The result table cellpadding(default is 3): </label><br /> 438 <input type="text" id="<?php echo $this->get_field_id( 'cpad' ); ?>" name="<?php echo $this->get_field_name( 'cpad' ); ?>" value="<?php echo $instance['cpad'];?>" size="4"/> 439 <br /> 440 <label for="<?php echo $this->get_field_id( 'cpin' ); ?>">The result table cellspacing(default is 3): </label><br /> 441 <input type="text" id="<?php echo $this->get_field_id( 'cpin' ); ?>" name="<?php echo $this->get_field_name( 'cpin' ); ?>" value="<?php echo $instance['cpin'];?>" size="4"/> 442 <br /> 443 <label>The result list will be a table, that uses the css class 'wp_ytbnstb', so you can play with the table properties, and the inside elements.</label><br /> 444 <input type="hidden" id="youtubenails-Submit" name="youtubenails-Submit" value="1" /> 445 </p> 446 <?php 447 } 448 } 449 ?>
Note: See TracChangeset
for help on using the changeset viewer.