'latest-posts-widget', 'description' => __('List latest posts of your site with thumbnails', 'bizstrait'), ); parent::__construct('latest-posts-widget', __('Bizstrait Latest Posts', 'bizstrait'), $widget_ops); } // Displays latest posts widget on blog. function widget($args, $instance) { global $post; extract($args); // $sizes = get_option( 'mkrdip_latest_posts_thumb_sizes' ); $valid_sort_orders = array('date', 'title', 'comment_count', 'rand'); if (in_array($instance['sort_by'], $valid_sort_orders)) { $sort_by = $instance['sort_by']; $sort_order = (bool) isset($instance['asc_sort_order']) ? 'ASC' : 'DESC'; } else { // by default, display latest first $sort_by = 'date'; $sort_order = 'DESC'; } // Get array of post info. $cat_posts = new WP_Query( array( 'posts_per_page' => $instance['num'], 'orderby' => $sort_by, 'order' => $sort_order, ) ); echo wp_kses_post($before_widget); // Widget title if (!empty($instance['title'])) { echo wp_kses_post($before_title); echo wp_kses_post($instance['title']); echo wp_kses_post($after_title); } // Post list echo "