Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class avia_combo_widget extends WP_Widget {
- function avia_combo_widget() {
- //Constructor
- $widget_ops = array('classname' => 'avia_combo_widget', 'description' => 'A widget that displays your popular posts, recent posts, recent comments and a tagcloud' );
- $this->WP_Widget( 'avia_combo_widget', THEMENAME.' Combo Widget', $widget_ops );
- }
- function widget($args, $instance)
- {
- // prints the widget
- extract($args, EXTR_SKIP);
- $posts = empty($instance['count']) ? 4 : $instance['count'];
- echo $before_widget;
- echo "<div class='tabcontainer border_tabs top_tab tab_initial_open tab_initial_open__1'>";
- echo '<div class="tab widget_tab_popular"><span>'.__('Popular', 'avia_framework').'</span></div>';
- echo "<div class='tab_content active_tab_content'>";
- avia_get_post_list('cat=&orderby=comment_count&posts_per_page='.$posts);
- echo "</div>";
- echo '<div class="tab active_tab first_tab widget_tab_recent"><span>'.__('Recent', 'avia_framework').'</span></div>';
- echo "<div class='tab_content'>";
- avia_get_post_list('showposts='. $posts .'&orderby=post_date&order=desc');
- echo "</div>";
- echo '<div class="tab widget_tab_comments"><span>'.__('Comments', 'avia_framework').'</span></div>';
- echo "<div class='tab_content'>";
- avia_get_comment_list( array('number' => $posts, 'status' => 'approve', 'order' => 'DESC') );
- echo "</div>";
- echo '<div class="tab last_tab widget_tab_tags"><span>'.__('Tags', 'avia_framework').'</span></div>';
- echo "<div class='tab_content tagcloud'>";
- wp_tag_cloud('smallest=12&largest=12&unit=px');
- echo "</div>";
- echo "</div>";
- echo $after_widget;
- }
- function update($new_instance, $old_instance)
- {
- $instance = $old_instance;
- foreach($new_instance as $key=>$value)
- {
- $instance[$key] = strip_tags($new_instance[$key]);
- }
- return $instance;
- }
- function form($instance) {
- //widgetform in backend
- $instance = wp_parse_args( (array) $instance, array('count' => 4) );
- if(!is_numeric($instance['count'])) $instance['count'] = 4;
- ?>
- <p>
- <label for="<?php echo $this->get_field_id('count'); ?>">Number of posts you want to display:
- <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>
- <?php
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement