'post_list_widget', 'description' => esc_html__( 'Display a list of popular posts', 'nanopress' ) ); parent::__construct('nanopress_popular_widget', esc_html__('jellywp: popular post', 'nanopress'), $widget_ops); } /*-----------------------------------------------------------------------------------*/ /* Display Widget /*-----------------------------------------------------------------------------------*/ function widget( $args, $instance ) { extract( $args ); $title = apply_filters('Popular Posts', $instance['title'] ); $num_posts = $instance['num_posts']; echo '
'; if ( $title ){ print $before_title . esc_attr($title) . $after_title; } print $before_widget; $recent_posts = new WP_Query(array( 'showposts' => $num_posts, 'orderby' => 'comment_count', 'ignore_sticky_posts' => 1 )); ?>
"; } /*-----------------------------------------------------------------------------------*/ /* Update Widget /*-----------------------------------------------------------------------------------*/ function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags( $new_instance['title'] ); $instance['num_posts'] = $new_instance['num_posts']; return $instance; } /*-----------------------------------------------------------------------------------*/ /* Widget Settings (Displays the widget settings controls on the widget panel) /*-----------------------------------------------------------------------------------*/ function form($instance) { $defaults = array('title' => esc_html__( 'Popular Posts', 'nanopress' ) , 'num_posts' => 4, 'show_comments' => 'on'); $instance = wp_parse_args((array) $instance, $defaults); ?>