'business_x_slider_top_middle', 'description' => esc_html__( "The most recent posts on your site", 'business-x') ); parent::__construct('recent-posts-middle1', esc_html__('BX : Top Middle Slider', 'business-x'), $widget_ops); $this->alt_option_name = 'widget_recent_entries_middle1'; add_action( 'save_post', array($this, 'business_x_slider_top_middle_flush_widget_cache') ); add_action( 'deleted_post', array($this, 'business_x_slider_top_middle_flush_widget_cache') ); add_action( 'switch_theme', array($this, 'business_x_slider_top_middle_flush_widget_cache') ); } function widget($args, $instance) { wp_enqueue_script( 'business-x-slider-top-middle', get_template_directory_uri().'/inc/widgets/business-x-slider-top-middle/top_middle.js',array('jquery'),null, false); $business_x_slider_top_middle_flush_widget_cache = wp_cache_get('business_x_slider_top_middle', 'widget'); if ( !is_array($business_x_slider_top_middle_flush_widget_cache) ) $business_x_slider_top_middle_flush_widget_cache = array(); if ( ! isset( $args['widget_id'] ) ) $args['widget_id'] = $this->id; if ( isset( $business_x_slider_top_middle_flush_widget_cache[ $args['widget_id'] ] ) ) { echo esc_attr($business_x_slider_top_middle_flush_widget_cache[ $args['widget_id'] ]); return; } ob_start(); extract($args); $category_list = isset($instance['category']) ? $instance['category'] : ''; $title = isset( $instance['title'] ) ? $instance['title'] : ''; $number = isset( $instance['number'] ) ? $instance['number'] : ''; ?> $number,'category__in' => $category_list, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) ); if ($business_x_slider_top_middle_r->have_posts()) : echo $args['before_widget']; ?>
have_posts() ) : $business_x_slider_top_middle_r->the_post(); $post_id = get_the_ID(); $category = get_the_category($post_id); if (has_post_thumbnail()){ $image_array = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'large'); $image = $image_array[0]; }else{ $image = get_template_directory_uri() .'/assets/images/no-image.png'; } if($count < $number ): ?>
business_x_slider_top_middle_flush_widget_cache(); $alloptions = wp_cache_get( 'alloptions', 'options' ); if ( isset($alloptions['business_x_slider_top_middle_flush_widget_cache']) ) delete_option('business_x_slider_top_middle_flush_widget_cache'); return $instance; } function business_x_slider_top_middle_flush_widget_cache() { wp_cache_delete('business_x_slider_top_middle_flush_widget_cache', 'widget'); } function form( $instance ) { $category_list = isset($instance['category']) ? esc_attr($instance['category']) : ''; $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 10; ?>

' Select', 'name'=> $this->get_field_name('category'),'selected'=> $category_list)); ?>