'editorial_featured_slider clearfix', 'description' => __( 'Display slider with featured posts.', 'editorial' ) ); parent::__construct( 'editorial_featured_slider', __( 'Editorial: Featured Slider', 'editorial' ), $widget_ops ); } /** * Helper function that holds widget fields * Array is used in update and form functions */ private function widget_fields() { $editorial_category_dropdown = editorial_category_dropdown(); $fields = array( 'slider_header_section' => array( 'editorial_widgets_name' => 'slider_header_section', 'editorial_widgets_title' => __( 'Slider Section', 'editorial' ), 'editorial_widgets_field_type' => 'widget_section_header' ), 'editorial_slider_category' => array( 'editorial_widgets_name' => 'editorial_slider_category', 'editorial_widgets_title' => __( 'Category for Slider', 'editorial' ), 'editorial_widgets_default' => 0, 'editorial_widgets_field_type' => 'select', 'editorial_widgets_field_options' => $editorial_category_dropdown ), 'editorial_slide_count' => array( 'editorial_widgets_name' => 'editorial_slide_count', 'editorial_widgets_title' => __( 'No. of slides', 'editorial' ), 'editorial_widgets_default' => 5, 'editorial_widgets_field_type' => 'number' ), 'featured_header_section' => array( 'editorial_widgets_name' => 'featured_header_section', 'editorial_widgets_title' => __( 'Featured Posts Section', 'editorial' ), 'editorial_widgets_field_type' => 'widget_section_header' ), 'editorial_featured_category' => array( 'editorial_widgets_name' => 'editorial_featured_category', 'editorial_widgets_title' => __( 'Category for Featured Posts', 'editorial' ), 'editorial_widgets_default' => 0, 'editorial_widgets_field_type' => 'select', 'editorial_widgets_field_options' => $editorial_category_dropdown ), ); return $fields; } /** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget( $args, $instance ) { extract( $args ); if( empty( $instance ) ) { return ; } $editorial_slider_category_id = intval( empty( $instance['editorial_slider_category'] ) ? null : $instance['editorial_slider_category'] ); $editorial_slide_count = intval( empty( $instance['editorial_slide_count'] ) ? 5 : $instance['editorial_slide_count'] ); $editorial_featured_category_id = intval( empty( $instance['editorial_featured_category'] ) ? null : $instance['editorial_featured_category'] ); echo $before_widget; ?>
post_count; if( $featured_query->have_posts() ) { $post_count = 1; while ( $featured_query->have_posts() ) { $featured_query->the_post(); $post_id = get_the_ID(); $image_path = get_the_post_thumbnail( $post_id, 'editorial-featured-medium' ); if( $post_count == 1 ) { echo '