Advertisement
Guest User

widget

a guest
Jun 28th, 2015
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.45 KB | None | 0 0
  1. class avia_combo_widget extends WP_Widget {
  2.  
  3.   function avia_combo_widget() {
  4.     //Constructor
  5.     $widget_ops = array('classname' => 'avia_combo_widget', 'description' => 'A widget that displays your popular posts, recent posts, recent comments and a tagcloud' );
  6.     $this->WP_Widget( 'avia_combo_widget', THEMENAME.' Combo Widget', $widget_ops );
  7.   }
  8.  
  9.   function widget($args, $instance)
  10.   {
  11.     // prints the widget
  12.  
  13.     extract($args, EXTR_SKIP);
  14.     $posts = empty($instance['count']) ? 4 : $instance['count'];
  15.  
  16.     echo $before_widget;
  17.     echo "<div class='tabcontainer border_tabs top_tab tab_initial_open tab_initial_open__1'>";
  18.  
  19.     echo '<div class="tab widget_tab_popular"><span>'.__('Popular', 'avia_framework').'</span></div>';
  20.     echo "<div class='tab_content active_tab_content'>";
  21.     avia_get_post_list('cat=&orderby=comment_count&posts_per_page='.$posts);
  22.     echo "</div>";
  23.  
  24.     echo '<div class="tab active_tab first_tab widget_tab_recent"><span>'.__('Recent', 'avia_framework').'</span></div>';
  25.     echo "<div class='tab_content'>";
  26.     avia_get_post_list('showposts='. $posts .'&orderby=post_date&order=desc');
  27.     echo "</div>";
  28.  
  29.     echo '<div class="tab widget_tab_comments"><span>'.__('Comments', 'avia_framework').'</span></div>';
  30.     echo "<div class='tab_content'>";
  31.     avia_get_comment_list( array('number' => $posts, 'status' => 'approve', 'order' => 'DESC') );
  32.     echo "</div>";
  33.  
  34.     echo '<div class="tab last_tab widget_tab_tags"><span>'.__('Tags', 'avia_framework').'</span></div>';
  35.     echo "<div class='tab_content tagcloud'>";
  36.     wp_tag_cloud('smallest=12&largest=12&unit=px');
  37.     echo "</div>";
  38.  
  39.     echo "</div>";
  40.     echo $after_widget;
  41.   }
  42.  
  43.  
  44.   function update($new_instance, $old_instance)
  45.   {
  46.     $instance = $old_instance;
  47.     foreach($new_instance as $key=>$value)
  48.     {
  49.       $instance[$key]   = strip_tags($new_instance[$key]);
  50.     }
  51.  
  52.     return $instance;
  53.   }
  54.  
  55.   function form($instance) {
  56.     //widgetform in backend
  57.  
  58.     $instance = wp_parse_args( (array) $instance, array('count' => 4) );
  59.     if(!is_numeric($instance['count'])) $instance['count'] = 4;
  60.  
  61. ?>
  62.     <p>
  63.     <label for="<?php echo $this->get_field_id('count'); ?>">Number of posts you want to display:
  64.     <input class="widefat" id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>" type="text" value="<?php echo esc_attr($instance['count']); ?>" /></label></p>
  65.  
  66.  
  67.   <?php
  68.   }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement