esc_html__('Fairy Featured Posts', 'across'), 'cat' => 0, 'post-number' => 5, 'post-date' => 1, 'show-category' => 1 ); return $defaults; } public function __construct() { $opts = array( 'classname' => 'across-featured-posts', 'description' => esc_html__('Display post in Slider Form. Suitable on Sidebars.', 'across'), ); parent::__construct('across-featured-posts', esc_html__('Fairy Featured Posts', 'across'), $opts); } public function widget($args, $instance) { $instance = wp_parse_args((array) $instance, $this->defaults()); $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); echo $args['before_widget']; $cat_id = !empty($instance['cat']) ? $instance['cat'] : ''; $post_number = !empty($instance['post-number']) ? $instance['post-number'] : ''; $post_date = !empty($instance['post-date']) ? $instance['post-date'] : ''; $show_category = !empty($instance['show-category']) ? $instance['show-category'] : ''; if (!empty($title)) { $cat_class = 'cat-' . $cat_id; ?>
'post', 'cat' => absint($cat_id), 'posts_per_page' => absint($post_number), 'ignore_sticky_posts' => true ); $query = new WP_Query($query_args); if ($query->have_posts()) : ?> defaults()); $title = esc_attr($instance['title']); $post_number = absint($instance['post-number']); $post_date = absint($instance['post-date']); $show_category = absint($instance['show-category']); ?>
'name', 'hide_empty' => 0, 'id' => $this->get_field_id('cat'), 'name' => $this->get_field_name('cat'), 'class' => 'widefat', 'taxonomy' => 'category', 'selected' => absint($instance['cat']), 'show_option_all' => esc_html__('Show Recent Posts', 'across') ); wp_dropdown_categories($cat_args); ?>
/>
/>