text_fields = array('storecommerce-posts-latest-title', 'storecommerce-posts-latest-subtitle', 'storecommerce-number-of-items'); $this->select_fields = array('storecommerce-show-excerpt', 'storecommerce-select-category', 'storecommerce-show-all-link'); $widget_ops = array( 'classname' => 'posts_latest_widget', 'description' => __('Displays latest posts lists from selected category.', 'storecommerce'), 'customize_selective_refresh' => true, ); parent::__construct('product_posts_latest', __('AFTSC Latest Posts', 'storecommerce'), $widget_ops); } /** * 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) { $instance = parent::storecommerce_sanitize_data($instance, $instance); $title = apply_filters('widget_title', $instance['storecommerce-posts-latest-title'], $instance, $this->id_base); $subtitle = isset($instance['storecommerce-posts-latest-subtitle']) ? $instance['storecommerce-posts-latest-subtitle'] : ''; $show_exceprt = isset($instance['storecommerce-show-excerpt']) ? $instance['storecommerce-show-excerpt'] : 'true'; // open the widget container echo $args['before_widget']; ?>

have_posts()) : while ($all_posts->have_posts()) : $all_posts->the_post(); if (has_post_thumbnail()) { $thumb = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'storecommerce-medium-square'); $url = $thumb['0']; } else { $url = ''; } global $post; ?>
ID); ?>

form_instance = $instance; $options = array( 'true' => __('Yes', 'storecommerce'), 'false' => __('No', 'storecommerce'), ); // generate the text input for the title of the widget. Note that the first parameter matches text_fields array entry $categories = storecommerce_get_terms('category'); // generate the text input for the title of the widget. Note that the first parameter matches text_fields array entry echo parent::storecommerce_generate_text_input('storecommerce-posts-latest-title', __('Title', 'storecommerce'), __('Latest Posts', 'storecommerce')); echo parent::storecommerce_generate_text_input('storecommerce-posts-latest-subtitle', __('Subtitle', 'storecommerce'), __('Latest Posts Subtitle', 'storecommerce')); echo parent::storecommerce_generate_select_options('storecommerce-show-excerpt', __('Show excerpt', 'storecommerce'), $options); } } endif;