function form($instance) { $defaults = array('title' => '', 'number_of_article' => 3, 'popular_title' => __('POPULAR', 'news-maxx-lite'), 'comment_title' => __('COMMENT', 'news-maxx-lite'), 'latest_title' => __('RECENT', 'news-maxx-lite'), 'kopa_timestamp' => ''); $instance = wp_parse_args((array) $instance, $defaults); $title = strip_tags($instance['title']); $form['number_of_article'] = $instance['number_of_article']; $form['popular_title'] = $instance['popular_title']; $form['comment_title'] = $instance['comment_title']; $form['latest_title'] = $instance['latest_title']; $form['kopa_timestamp'] = (int) $instance['kopa_timestamp']; ?> <p> <label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title:', 'news-maxx-lite'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo esc_attr($title); ?> " /> </p> <p> <label for="<?php echo $this->get_field_id('number_of_article'); ?> "><?php _e('Number of article:', 'news-maxx-lite'); ?> </label> <input class="widefat" type="number" min="1" id="<?php echo $this->get_field_id('number_of_article'); ?> " name="<?php echo $this->get_field_name('number_of_article'); ?> " value="<?php echo esc_attr($form['number_of_article']); ?> "> </p> <p> <label for="<?php echo $this->get_field_id('popular_title'); ?> "><?php _e('Popular tab title:', 'news-maxx-lite'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('popular_title'); ?> " name="<?php echo $this->get_field_name('popular_title'); ?> " type="text" value="<?php echo esc_attr($form['popular_title']); ?> "> <small><?php _e('Leave it <strong>empty</strong> to hide popular tab.', 'news-maxx-lite'); ?> </small> </p> <p> <label for="<?php echo $this->get_field_id('latest_title'); ?> "><?php _e('Latest tab title:', 'news-maxx-lite'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('latest_title'); ?> " name="<?php echo $this->get_field_name('latest_title'); ?> " type="text" value="<?php echo esc_attr($form['latest_title']); ?> "> <small><?php _e('Leave it <strong>empty</strong> to hide latest tab.', 'news-maxx-lite'); ?> </small> </p> <p> <label for="<?php echo $this->get_field_id('comment_title'); ?> "><?php _e('Comment tab title:', 'news-maxx-lite'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('comment_title'); ?> " name="<?php echo $this->get_field_name('comment_title'); ?> " type="text" value="<?php echo esc_attr($form['comment_title']); ?> "> <small><?php _e('Leave it <strong>empty</strong> to hide comment tab.', 'news-maxx-lite'); ?> </small> </p> <?php news_maxx_lite_print_timeago($this->get_field_id('kopa_timestamp'), $this->get_field_name('kopa_timestamp'), $form['kopa_timestamp']); ?> <?php }
function form($instance) { $default = array('title' => '', 'categories' => array(), 'relation' => 'OR', 'tags' => array(), 'kopa_timestamp' => '', 'posts_per_page' => 6, 'orderby' => 'latest'); $instance = wp_parse_args((array) $instance, $default); $title = strip_tags($instance['title']); $form['categories'] = $instance['categories']; $form['relation'] = esc_attr($instance['relation']); $form['tags'] = $instance['tags']; $form['kopa_timestamp'] = $instance['kopa_timestamp']; $form['posts_per_page'] = (int) $instance['posts_per_page']; $form['orderby'] = $instance['orderby']; ?> <p> <label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title:', 'news-maxx-lite'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo esc_attr($title); ?> " /> </p> <p> <label for="<?php echo $this->get_field_id('categories'); ?> "><?php _e('Categories', 'news-maxx-lite'); ?> </label> <select class="widefat" id="<?php echo $this->get_field_id('categories'); ?> " name="<?php echo $this->get_field_name('categories'); ?> []" multiple="multiple" size="5"> <option value=""><?php _e('--Select--', 'news-maxx-lite'); ?> </option> <?php $categories = get_categories(); foreach ($categories as $category) { ?> <option value="<?php echo $category->term_id; ?> " <?php echo in_array($category->term_id, $form['categories']) ? 'selected="selected"' : ''; ?> > <?php echo $category->name . ' (' . $category->count . ')'; ?> </option> <?php } ?> </select> </p> <p> <label for="<?php echo $this->get_field_id('relation'); ?> "><?php _e('Relation', 'news-maxx-lite'); ?> :</label> <select class="widefat" name="<?php echo $this->get_field_name('relation'); ?> " id="<?php echo $this->get_field_id('relation'); ?> "> <option value="OR" <?php selected('OR', $form['relation']); ?> ><?php _e('OR', 'news-maxx-lite'); ?> </option> <option value="AND" <?php selected('AND', $form['relation']); ?> ><?php _e('AND', 'news-maxx-lite'); ?> </option> </select> </p> <p> <label for="<?php echo $this->get_field_id('tags'); ?> "><?php _e('Tags', 'news-maxx-lite'); ?> </label> <select class="widefat" id="<?php echo $this->get_field_id('tags'); ?> " name="<?php echo $this->get_field_name('tags'); ?> []" multiple="multiple" size="5"> <option value=""><?php _e('--Select--', 'news-maxx-lite'); ?> </option> <?php $tags = get_tags(); foreach ($tags as $category) { ?> <option value="<?php echo $category->term_id; ?> " <?php echo in_array($category->term_id, $form['tags']) ? 'selected="selected"' : ''; ?> > <?php echo $category->name . ' (' . $category->count . ')'; ?> </option> <?php } ?> </select> </p> <?php news_maxx_lite_print_timeago($this->get_field_id('kopa_timestamp'), $this->get_field_name('kopa_timestamp'), $form['kopa_timestamp']); ?> <p> <label for="<?php echo $this->get_field_id('orderby'); ?> "><?php _e('Orderby', 'news-maxx-lite'); ?> </label> <select class="widefat" name="<?php echo $this->get_field_name('orderby'); ?> " id="<?php echo $this->get_field_id('orderby'); ?> "> <?php $orderby = array('latest' => __('Latest', 'news-maxx-lite'), 'popular' => __('Popular by view count', 'news-maxx-lite'), 'most_comment' => __('Popular by comment count', 'news-maxx-lite'), 'random' => __('Random', 'news-maxx-lite')); foreach ($orderby as $value => $label) { ?> <option value="<?php echo $value; ?> " <?php selected($value, $form['orderby']); ?> ><?php echo $label; ?> </option> <?php } ?> </select> </p> <p> <label for="<?php echo $this->get_field_id('posts_per_page'); ?> "><?php _e('Number of items:', 'news-maxx-lite'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('posts_per_page'); ?> " name="<?php echo $this->get_field_name('posts_per_page'); ?> " value="<?php echo $form['posts_per_page']; ?> " type="number" min="1"> </p> <?php }
function form($instance) { $default = array('title' => '', 'categories' => array(), 'relation' => 'OR', 'tags' => array(), 'posts_per_page' => 4, 'limit' => 10, 'kopa_timestamp' => '', 'orderby' => 'latest', 'slide_speed' => 700, 'is_auto_play' => 'false', 'display' => 'fullwidth_image'); $instance = wp_parse_args((array) $instance, $default); $title = strip_tags($instance['title']); $limit = (int) $instance['limit']; $form['categories'] = $instance['categories']; $form['relation'] = esc_attr($instance['relation']); $form['tags'] = $instance['tags']; $form['posts_per_page'] = (int) $instance['posts_per_page']; $form['kopa_timestamp'] = (int) $instance['kopa_timestamp']; $form['orderby'] = $instance['orderby']; $form['display'] = $instance['display']; $form['slide_speed'] = $instance['slide_speed']; $form['is_auto_play'] = $instance['is_auto_play']; ?> <div class="kopa-one-half"> <p> <label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title:', 'news-maxx-lite'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo esc_attr($title); ?> " /> </p> <p> <label for="<?php echo $this->get_field_id('categories'); ?> "><?php _e('Categories', 'news-maxx-lite'); ?> </label> <select class="widefat" id="<?php echo $this->get_field_id('categories'); ?> " name="<?php echo $this->get_field_name('categories'); ?> []" multiple="multiple" size="5"> <option value=""><?php _e('--Select--', 'news-maxx-lite'); ?> </option> <?php $categories = get_categories(); foreach ($categories as $category) { ?> <option value="<?php echo $category->term_id; ?> " <?php echo in_array($category->term_id, $form['categories']) ? 'selected="selected"' : ''; ?> > <?php echo $category->name . ' (' . $category->count . ')'; ?> </option> <?php } ?> </select> </p> <p> <label for="<?php echo $this->get_field_id('relation'); ?> "><?php _e('Relation', 'news-maxx-lite'); ?> :</label> <select class="widefat" name="<?php echo $this->get_field_name('relation'); ?> " id="<?php echo $this->get_field_id('relation'); ?> "> <option value="OR" <?php selected('OR', $form['relation']); ?> ><?php _e('OR', 'news-maxx-lite'); ?> </option> <option value="AND" <?php selected('AND', $form['relation']); ?> ><?php _e('AND', 'news-maxx-lite'); ?> </option> </select> </p> <p> <label for="<?php echo $this->get_field_id('tags'); ?> "><?php _e('Tags', 'news-maxx-lite'); ?> </label> <select class="widefat" id="<?php echo $this->get_field_id('tags'); ?> " name="<?php echo $this->get_field_name('tags'); ?> []" multiple="multiple" size="5"> <option value=""><?php _e('--Select--', 'news-maxx-lite'); ?> </option> <?php $tags = get_tags(); foreach ($tags as $category) { ?> <option value="<?php echo $category->term_id; ?> " <?php echo in_array($category->term_id, $form['tags']) ? 'selected="selected"' : ''; ?> > <?php echo $category->name . ' (' . $category->count . ')'; ?> </option> <?php } ?> </select> </p> <?php news_maxx_lite_print_timeago($this->get_field_id('kopa_timestamp'), $this->get_field_name('kopa_timestamp'), $form['kopa_timestamp']); ?> <p> <label for="<?php echo $this->get_field_id('orderby'); ?> "><?php _e('Orderby', 'news-maxx-lite'); ?> </label> <select class="widefat" name="<?php echo $this->get_field_name('orderby'); ?> " id="<?php echo $this->get_field_id('orderby'); ?> "> <?php $orderby = array('latest' => __('Latest', 'news-maxx-lite'), 'popular' => __('Popular by view count', 'news-maxx-lite'), 'most_comment' => __('Popular by comment count', 'news-maxx-lite'), 'random' => __('Random', 'news-maxx-lite')); foreach ($orderby as $value => $label) { ?> <option value="<?php echo $value; ?> " <?php selected($value, $form['orderby']); ?> ><?php echo $label; ?> </option> <?php } ?> </select> </p> <p> <label for="<?php echo $this->get_field_id('posts_per_page'); ?> "><?php _e('Number of items:', 'news-maxx-lite'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('posts_per_page'); ?> " name="<?php echo $this->get_field_name('posts_per_page'); ?> " value="<?php echo $form['posts_per_page']; ?> " type="number" min="1"> </p> <p> <label for="<?php echo $this->get_field_id('limit'); ?> "><?php _e('Number words of post excerpt:', 'news-maxx-lite'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('limit'); ?> " name="<?php echo $this->get_field_name('limit'); ?> " type="text" value="<?php echo $limit; ?> " /> </p> <p> <label for="<?php echo $this->get_field_id('display'); ?> "><?php _e('Display:', 'news-maxx-lite'); ?> </label> <select class="widefat" name="<?php echo $this->get_field_name('display'); ?> " id="<?php echo $this->get_field_id('display'); ?> "> <?php $display = array('grid_layout_random_flexible_size' => __('Display random articles in flexible grid layout', 'news-maxx-lite'), 'grid_with_3items_per_page' => __('Grid with three items per page', 'news-maxx-lite')); foreach ($display as $value => $label) { ?> <option value="<?php echo $value; ?> " <?php selected($value, $form['display']); ?> ><?php echo $label; ?> </option> <?php } ?> </select> </p> </div> <div class="kopa-one-half last"> <p> <label for="<?php echo $this->get_field_id('slide_speed'); ?> "><?php _e('Slide speed:', 'news-maxx-lite'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('slide_speed'); ?> " name="<?php echo $this->get_field_name('slide_speed'); ?> " value="<?php echo $form['slide_speed']; ?> " type="number" min="1"> <small><?php _e('Slide speed in milliseconds', 'news-maxx-lite'); ?> </small> </p> <p> <input id="<?php echo $this->get_field_id('is_auto_play'); ?> " name="<?php echo $this->get_field_name('is_auto_play'); ?> " type="checkbox" value="true" <?php echo 'true' === $form['is_auto_play'] ? 'checked="checked"' : ''; ?> /> <label for="<?php echo $this->get_field_id('is_auto_play'); ?> "><?php _e('Auto Play', 'news-maxx-lite'); ?> </label> </p> </div> <div class="kopa-clear"></div> <?php }