'business_brand_slider_top_middle', 'description' => esc_html__( "The most recent posts on your site", 'business-brand') ); parent::__construct('recent-posts-middle1', esc_html__('BX : Top Middle Slider', 'business-brand'), $widget_ops); $this->alt_option_name = 'widget_recent_entries_middle1'; add_action( 'save_post', array($this, 'business_brand_slider_top_middle_flush_widget_cache') ); add_action( 'deleted_post', array($this, 'business_brand_slider_top_middle_flush_widget_cache') ); add_action( 'switch_theme', array($this, 'business_brand_slider_top_middle_flush_widget_cache') ); } function widget($args, $instance) { wp_enqueue_script( 'business-brand-slider-top-middle', get_template_directory_uri().'/inc/widgets/business-brand-slider-top-middle/top_middle.js',array('jquery'),null, false); $business_brand_slider_top_middle_flush_widget_cache = wp_cache_get('business_brand_slider_top_middle', 'widget'); if ( !is_array($business_brand_slider_top_middle_flush_widget_cache) ) $business_brand_slider_top_middle_flush_widget_cache = array(); if ( ! isset( $args['widget_id'] ) ) $args['widget_id'] = $this->id; if ( isset( $business_brand_slider_top_middle_flush_widget_cache[ $args['widget_id'] ] ) ) { echo esc_attr($business_brand_slider_top_middle_flush_widget_cache[ $args['widget_id'] ]); return; } ob_start(); extract($args); $category_list = isset($instance['category']) ? absint($instance['category']) : ''; $title = isset( $instance['title'] ) ? sanitize_text_field($instance['title']) : ''; $number = isset( $instance['number'] ) ? absint($instance['number']) : ''; ?> $number,'category__in' => $category_list, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) ); if ($business_brand_slider_top_middle_r->have_posts()) : echo $args['before_widget']; ?>
have_posts() ) : $business_brand_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 ): ?>
0 ) ? absint($new_instance['category']):''; $instance['title'] = (!empty( $new_instance['title']) && $new_instance['title'] !='' ) ? sanitize_text_field($new_instance['title']):''; $instance['number'] = isset( $new_instance['number'] ) ? absint( $new_instance['number'] ) : 10; $this->business_brand_slider_top_middle_flush_widget_cache(); $alloptions = wp_cache_get( 'alloptions', 'options' ); if ( isset($alloptions['business_brand_slider_top_middle_flush_widget_cache']) ) delete_option('business_brand_slider_top_middle_flush_widget_cache'); return $instance; } function business_brand_slider_top_middle_flush_widget_cache() { wp_cache_delete('business_brand_slider_top_middle_flush_widget_cache', 'widget'); } function form( $instance ) { $category_list = isset($instance['category']) ? absint($instance['category']) : ''; $title = isset( $instance['title'] ) ? sanitize_text_field( $instance['title'] ) : ''; $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 10; ?>

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