'business_x_category_widget_recent_posts_template2', 'description' => esc_html__( "The most recent posts on your site", 'business-x') ); parent::__construct('category-posts-template1', esc_html__('BX : Recent Category Post(Style 2)', 'business-x'), $widget_ops); $this->alt_option_name = 'widget_recent_post_template1'; add_action( 'save_post', array($this, 'business_x_category_flush_widget_cache_temlate3') ); add_action( 'deleted_post', array($this, 'business_x_category_flush_widget_cache_temlate3') ); add_action( 'switch_theme', array($this, 'business_x_category_flush_widget_cache_temlate3') ); } function widget($args, $instance) { wp_enqueue_style( 'business-x-template2', get_template_directory_uri().'/inc/widgets/business-x-category-widgets-style2/style2.css',array(),null, false); $business_x_category_cache = wp_cache_get('business_x_category_widget_recent_posts_template2', 'widget'); if ( !is_array($business_x_category_cache) ) $business_x_category_cache = array(); if ( ! isset( $args['widget_id'] ) ) $args['widget_id'] = $this->id; if ( isset( $business_x_category_cache[ $args['widget_id'] ] ) ) { echo esc_attr($business_x_category_cache[ $args['widget_id'] ]); return; } ob_start(); extract($args); $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : esc_html__( 'Recent Posts', 'business-x' ); $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 3; $category_list = isset($instance['category']) ? $instance['category'] : ''; if ( ! $number ) $number = 3; ?> $number,'category__in' => $category_list, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) ); if ($business_x_category_r->have_posts()) : echo $args['before_widget']; if ( $title ) echo $args['before_title'] . esc_html($title) . $args['after_title']; ?>
' Select', 'name'=> $this->get_field_name('category'),'selected'=> $category_list)); ?>