Advertisement
caledoniaman

Untitled

Aug 6th, 2012
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.44 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: News Filter widget
  4. Plugin URI: http://uservision.co.uk/
  5. Description: Widget for displaying news archive in sidebar
  6. Author: Mark Palmer
  7. Version: 1
  8. Author URI: http://markpalmer.org/
  9. */
  10.  
  11.  
  12. class NewsFilterWidget extends WP_Widget
  13. {
  14.   function NewsFilterWidget()
  15.   {
  16.     $widget_ops = array('classname' => 'NewsFilterWidget', 'description' => 'Display News Filter Panel' );
  17.     $this->WP_Widget('NewsFilterWidget', 'News Filter Panel', $widget_ops);
  18.   }
  19.  
  20.   function form($instance)
  21.   {
  22.     $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
  23.     $title = $instance['title'];
  24. ?>
  25. <?php
  26.   }
  27.  
  28.   function update($new_instance, $old_instance)
  29.   {
  30.     $instance = $old_instance;
  31.     $instance['title'] = $new_instance['title'];
  32.     return $instance;
  33.   }
  34.  
  35.   function widget($args, $instance)
  36.   {
  37.     extract($args, EXTR_SKIP);
  38.  
  39.     echo $before_widget;
  40.     $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);
  41.  
  42.     if (!empty($title))
  43.       echo "";
  44.     ?>
  45.      
  46.     <h4>View by topic</h4>
  47.     <ul>
  48.         <?php wp_list_categories('orderby=id&show_count=1&use_desc_for_title=0&title_li=&child_of=1&exclude=42'); ?>
  49.     </ul>
  50.     <h4>View by year</h4>
  51.     <ul>
  52.         <?php wp_get_archives('type=yearly&cat=1'); ?>
  53.     </ul>
  54.     <?php echo $after_widget;
  55.    
  56.   }
  57.  
  58. }
  59. add_action( 'widgets_init', create_function('', 'return register_widget("NewsFilterWidget");') );?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement