__( 'Displays posts with most comments.', 'newsmag' ), 'classname' => 'popular-posts', 'customize_selective_refresh' => true ) ); } public function widget( $args, $instance ) { $defaults = array( 'title' => __( 'Popular posts', 'newsmag' ), 'number' => 5, ); $instance = wp_parse_args( (array) $instance, $defaults ); $instance['title'] = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); $r = new WP_Query( array( 'posts_per_page' => $instance['number'], 'offset' => 0, 'orderby' => 'comment_count' ) ); wp_reset_postdata(); if ( $r->have_posts() ) : ?> ! empty( $new['title'] ) ? strip_tags( $new['title'] ) : '', 'number' => ! empty( $new['show_post'] ) ? absint( $new['number'] ) : '', ); return $instance; } public function form( $instance ) { $defaults = array( 'title' => __( 'Popular posts', 'newsmag' ), 'number' => 5, ); $instance = wp_parse_args( (array) $instance, $defaults ); ?>