__( 'A widget To Display Services', 'aglee-lite' ) ) ); } /** * Helper function that holds widget fields * Array is used in update and form functions */ private function widget_fields() { $fields = array( 'service_post_1' => array( 'aglee_widgets_name' => 'service_post_1', 'aglee_widgets_title' => __('Post','aglee-lite'), 'aglee_widgets_field_type' => 'selectpost' ), 'service_post_2' => array( 'aglee_widgets_name' => 'service_post_2', 'aglee_widgets_title' => __('Post','aglee-lite'), 'aglee_widgets_field_type' => 'selectpost' ), 'service_post_3' => array( 'aglee_widgets_name' => 'service_post_3', 'aglee_widgets_title' => __('Post','aglee-lite'), 'aglee_widgets_field_type' => 'selectpost' ), 'service_post_4' => array( 'aglee_widgets_name' => 'service_post_4', 'aglee_widgets_title' => __('Post','aglee-lite'), 'aglee_widgets_field_type' => 'selectpost' ) ); 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 ) { //print_r($args); extract( $args ); $services_readmore_text = get_theme_mod('home_page_moreinfo');//$aglee_settings['services_readmore_text']; $service_posts = array_values($instance); if(!empty($service_posts)) : echo $before_widget; $args = array( 'posts_per_page' => 4, 'post_type' => array('Post'), 'post__in' => $service_posts, 'orderby' => 'post__in' ); $feat_query = new WP_Query($args); if($feat_query->have_posts()) : ?>

have_posts()) : $feat_query->the_post(); $img = wp_get_attachment_image_src(get_post_thumbnail_id(),'services-thumb', true); $img_src = $img[0]; ?>
<?php the_title_attribute(); ?>
widget_fields(); // Loop through fields foreach( $widget_fields as $widget_field ) { extract( $widget_field ); // Use helper function to get updated field values $instance[$aglee_widgets_name] = aglee_lite_widgets_updated_field_value( $widget_field, $new_instance[$aglee_widgets_name] ); echo $instance[$aglee_widgets_name]; } return $instance; } /** * Back-end widget form. * * @see WP_Widget::form() * * @param array $instance Previously saved values from database. * * @uses aglee_lite_widgets_show_widget_field() defined in widget-fields.php */ public function form( $instance ) { $widget_fields = $this->widget_fields(); // Loop through fields foreach( $widget_fields as $widget_field ) { // Make array elements available as variables extract( $widget_field ); $aglee_widgets_field_value = isset( $instance[$aglee_widgets_name] ) ? esc_attr( $instance[$aglee_widgets_name] ) : ''; aglee_lite_widgets_show_widget_field( $this, $widget_field, $aglee_widgets_field_value ); } } }