* @copyright Copyright (c) 2021, AeonWP * @link https://aeonwp.com/aeonblog * @license http://www.gnu.org/licenses/gpl-2.0.html * * AeonMag post Slider Widget * * @since 1.0.0 */ if (!class_exists('AeonMag_Post_Column')) : /** * Highlight Post widget class. * * @since 1.0.0 */ class AeonMag_Post_Column extends WP_Widget { private function defaults() { $defaults = array( 'title' => esc_html__('Post Column', 'aeonmag' ), 'cat' => 0, 'post-number' => 5, 'excerpt-length'=> 15, ); return $defaults; } function __construct() { $opts = array( 'classname' => 'aeonmag-post-column', 'description' => esc_html__('Display post in Column Form. Suitable on home page widget.', 'aeonmag'), ); parent::__construct('aeonmag-post-column', esc_html__('AeonMag Post Column', 'aeonmag'), $opts); } 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']; if (!empty($title)) { echo $args['before_title'] . esc_html( $title ) . $args['after_title']; } $cat_id = !empty($instance['cat']) ? $instance['cat'] : ''; $post_number = !empty($instance['post-number']) ? $instance['post-number'] : ''; $excerpt_length = !empty($instance['excerpt-length']) ? $instance['excerpt-length'] : ''; $query_args = array( 'post_type' => 'post', 'cat' => absint($cat_id), 'posts_per_page' => absint($post_number), 'ignore_sticky_posts' => true ); $query = new WP_Query($query_args); ?>
defaults() ); ?>
'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', 'aeonmag') ); wp_dropdown_categories($cat_args); ?>