'widget_most_popular', 'description' => 'Add a widget to show the most popular posts', 'customize_selective_refresh' => true );
parent::__construct( 'widget_most_popular', THEMENAME.' Widget Popular Posts', $options );
}
function widget($atts, $instance){
extract($atts, EXTR_SKIP);
echo wp_kses_post( $before_widget );
$title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
$number_of_posts = empty($instance['number_of_posts']) ? '' : $instance['number_of_posts'];
$type = empty($instance['type']) ? 'popular' : $instance['type'];
if ( !empty( $title ) ) {
echo wp_kses_post( $before_title . $title . $after_title );
}
echo '
';
wp_reset_postdata();
echo wp_kses_post( $after_widget );
}
function update($new_instance, $old_instance){
$instance = array();
$instance['title'] = $new_instance['title'];
$instance['number_of_posts'] = $new_instance['number_of_posts'];
$instance['type'] = $new_instance['type'];
return $instance;
}
function form($instance){
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'number_of_posts' => '', 'type' => '') );
$title = isset($instance['title']) ? $instance['title']: "";
$number_of_posts = isset($instance['number_of_posts']) ? $instance['number_of_posts']: "";
$type = isset($instance['type']) ? $instance['type']: "";
?>