__( 'A widget To Display Feature Posts', 'accesspress-basic' ) ) ); } /** * Helper function that holds widget fields * Array is used in update and form functions */ private function widget_fields() { $fields = array( 'feature_post_1' => array( 'apbasic_widgets_name' => 'feature_post_1', 'apbasic_widgets_title' => __('Page','accesspress-basic'), 'apbasic_widgets_field_type' => 'selectpage' ), 'feature_post_2' => array( 'apbasic_widgets_name' => 'feature_post_2', 'apbasic_widgets_title' => __('Page','accesspress-basic'), 'apbasic_widgets_field_type' => 'selectpage' ), 'feature_post_3' => array( 'apbasic_widgets_name' => 'feature_post_3', 'apbasic_widgets_title' => __('Page','accesspress-basic'), 'apbasic_widgets_field_type' => 'selectpage' ), 'feature_post_4' => array( 'apbasic_widgets_name' => 'feature_post_4', 'apbasic_widgets_title' => __('Page','accesspress-basic'), 'apbasic_widgets_field_type' => 'selectpage' ), 'feature_post_5' => array( 'apbasic_widgets_name' => 'feature_post_5', 'apbasic_widgets_title' => __('Page','accesspress-basic'), 'apbasic_widgets_field_type' => 'selectpage' ), 'feature_post_6' => array( 'apbasic_widgets_name' => 'feature_post_6', 'apbasic_widgets_title' => __('Page','accesspress-basic'), 'apbasic_widgets_field_type' => 'selectpage' ), 'feature_text_length' => array( 'apbasic_widgets_name' => 'feature_text_length', 'apbasic_widgets_title' => __('Text Length','accesspress-basic'), 'apbasic_widgets_field_type' => 'text' ) ); 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 ); global $apbasic_options; $apbasic_settings = get_option('apbasic_options',$apbasic_options); $features_readmore_text = $apbasic_settings['features_readmore_text']; $feature_posts = array_values($instance); $feature_text_length = isset($instance['feature_text_length']) ? $instance['feature_text_length'] : 30; if(!empty($feature_posts)) : echo $before_widget; $args = array( 'posts_per_page' => -1, 'post_type' => array('page'), 'post__in' => $feature_posts, 'orderby' => 'post__in' ); $feat_query = new WP_Query($args); $count = 1; if($feat_query->have_posts()) : ?>
have_posts()) : $feat_query->the_post(); $img = wp_get_attachment_image_src(get_post_thumbnail_id(),'accesspress-basic-features-post-thumbnail'); $img_src = $img[0]; ?>
<?php the_title_attribute(); ?> <?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[$apbasic_widgets_name] = accesspress_basic_widgets_updated_field_value( $widget_field, $new_instance[$apbasic_widgets_name] ); echo $instance[$apbasic_widgets_name]; } return $instance; } /** * Back-end widget form. * * @see WP_Widget::form() * * @param array $instance Previously saved values from database. * * @uses accesspress_pro_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 ); $apbasic_widgets_field_value = isset( $instance[$apbasic_widgets_name] ) ? esc_attr( $instance[$apbasic_widgets_name] ) : ''; accesspress_basic_widgets_show_widget_field( $this, $widget_field, $apbasic_widgets_field_value ); } } }