*/ if ( ! defined( 'ABSPATH' ) ) { exit; // If this file is called directly, abort. } /** * Featured Posts Widget * * Class Aarambha_Kits_Block_Widget_4 */ class Aarambha_Kits_Block_Widget_4 extends Base_WP_Widget { /** * Constructor. */ public function __construct() { $this->widget_cssclass = 'widget_block widget-aarambha-kits'; $this->widget_description = esc_html__( 'Display latest posts or posts of specific category.', 'aarambha-kits' ); $this->widget_name = esc_html__( 'Aarambha Kits: Block Featured Posts', 'aarambha-kits' ); $this->settings = array( 'title' => array( 'type' => 'text', 'default' => '', 'label' => esc_html__( 'Title', 'aarambha-kits' ), ), 'style' => array( 'type' => 'select', 'default' => 'style-1', 'label' => esc_html__( 'Style', 'aarambha-kits' ), 'choices' => array( 'style-1' => esc_html__( 'Style 1', 'aarambha-kits' ), 'style-2' => esc_html__( 'Style 2', 'aarambha-kits' ), 'style-3' => esc_html__( 'Style 3', 'aarambha-kits' ), ), ), 'limit' => array( 'type' => 'number', 'default' => 5, 'label' => esc_html__( 'Posts Limit', 'aarambha-kits' ), 'input_attrs' => array( 'min' => 0, 'max' => 6, ), ), 'category' => array( 'type' => 'dropdown_categories', 'default' => '', 'label' => esc_html__( 'Select category', 'aarambha-kits' ), 'show_option_all' => esc_html__( 'All', 'aarambha-kits' ), ), ); parent::__construct(); } /** * Output widget. * * @see WP_Widget * * @param array $args Arguments. * @param array $instance Widget instance. */ public function widget( $args, $instance ) { $title = apply_filters( 'widget_title', isset( $instance['title'] ) ? $instance['title'] : '' ); $limit = isset( $instance['limit'] ) ? $instance['limit'] : 5; $style = isset( $instance['style'] ) ? $instance['style'] : 'style-1'; $wp_args = aarambha_kits_query_agrs( array( 'base_posts_limit' => $limit ), 1 ); if ( isset($instance['category']) ) { $wp_args = wp_parse_args( array( 'category__in' => absint( $instance['category'] ), ), $wp_args ); } $the_query = new WP_Query( $wp_args ); $this->widget_start( $args ); ?>