'fasto_recent_posts_widget', 'description' => esc_attr__('Display Recent Posts in a nice style','fasto') ); /* Widget control settings. */ $control_ops = array( 'id_base' => 'fasto_recent_posts_widget' ); /* Create the widget. */ parent::__construct( 'fasto_recent_posts_widget', esc_attr__('Fasto Recent Posts','fasto'), $widget_ops, $control_ops ); } function widget( $args, $instance ) { $post_no = !empty($instance['post_no']) ? strip_tags(absint($instance['post_no'])) : '' ; $title = !empty($instance['title']) ? strip_tags(esc_attr($instance['title'])) : '' ; $query_args = array( 'posts_per_page' => $post_no ); $query = new WP_Query( $query_args ); while ( $query->have_posts() ){ $query->the_post(); $is_gallery = get_post_format() == 'gallery' ? true : false; if ( $is_gallery ){ wp_enqueue_script( 'slick', fasto_URI."/js/slick.min.js", '', '', true ); continue; } } wp_reset_postdata(); extract( $args ); ?>