function form($instance) { $instance = wp_parse_args((array) $instance, array('title' => '', 'text' => '')); $title = strip_tags($instance['title']); $text = esc_textarea($instance['text']); $link = isset($instance['link']) ? $instance['link'] : ''; $button = isset($instance['button']) ? $instance['button'] : __('More', 'happykids'); /* ICON VARIABLES */ $title_select = isset($instance['title_select']) ? strval($instance['title_select']) : 'fa'; $title_fa = isset($instance['title_fa']) ? strip_tags($instance['title_fa']) : ''; $title_img = isset($instance['title_img']) ? strval($instance['title_img']) : ''; $display_none = ' style="display:none"'; $thumb_url = $title_img ? '="' . wp_get_attachment_thumb_url($title_img) . '"' : ''; $show_icon_options = isset($instance['show_icon_options']) ? $instance['show_icon_options'] : false; /* ICON VARIABLES */ ?> <p><label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title:', 'happykids'); ?> </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> <input type="checkbox" class="show_icon_options" id="<?php echo $this->get_field_id('show_icon_options'); ?> " name="<?php echo $this->get_field_name('show_icon_options'); ?> " <?php echo $show_icon_options == 'on' ? 'checked' : ''; ?> /> <label for="<?php echo $this->get_field_id('show_icon_options'); ?> "><?php _e("Show icon options", 'happykids'); ?> </label> </p> <!-- ICON SELECTION --> <?php $args = array('title_select' => $title_select, 'title_fa' => $title_fa, 'title_img' => $title_img, 'thumb_url' => $thumb_url, 'display_none' => $display_none, 'show_icon_options' => $show_icon_options, '_this' => $this, 'all' => true); cws_widget_icon_selection($args); ?> <!-- ICON SELECTION --> <textarea class="widefat" rows="16" cols="20" id="<?php echo $this->get_field_id('text'); ?> " name="<?php echo $this->get_field_name('text'); ?> "><?php echo $text; ?> </textarea> <p><input id="<?php echo $this->get_field_id('filter'); ?> " name="<?php echo $this->get_field_name('filter'); ?> " type="checkbox" <?php checked(isset($instance['filter']) ? $instance['filter'] : 0); ?> /> <label for="<?php echo $this->get_field_id('filter'); ?> "><?php _e('Automatically add paragraphs', 'happykids'); ?> </label></p> <p><input id="<?php echo $this->get_field_id('button'); ?> " name="<?php echo $this->get_field_name('button'); ?> " type="text" value="<?php echo !empty($button) ? $button : __('More', 'happykids'); ?> " /> <label for="<?php echo $this->get_field_id('button'); ?> "><?php _e('Button name', 'happykids'); ?> </label></p> <p><input id="<?php echo $this->get_field_id('link'); ?> " name="<?php echo $this->get_field_name('link'); ?> " type="text" value="<?php echo !empty($link) ? $link : ''; ?> " /> <label for="<?php echo $this->get_field_id('link'); ?> "><?php _e('Read more URL', 'happykids'); ?> </label></p> <?php }
function form($instance) { $title = isset($instance['title']) ? esc_attr($instance['title']) : 'Social Links'; $backlight = isset($instance['backlight']) ? $instance['backlight'] : false; /* ICON VARIABLES */ $title_select = isset($instance['title_select']) ? strval($instance['title_select']) : 'fa'; $title_fa = isset($instance['title_fa']) ? strip_tags($instance['title_fa']) : ''; $title_img = isset($instance['title_img']) ? strval($instance['title_img']) : ''; $display_none = ' style="display:none"'; $thumb_url = $title_img ? '="' . wp_get_attachment_thumb_url($title_img) . '"' : ''; $show_icon_options = isset($instance['show_icon_options']) ? $instance['show_icon_options'] : false; /* ICON VARIABLES */ ?> <p><label for="<?php echo $this->get_field_id('title'); ?> "><?php _e("Title: ", THEME_SLUG); ?> </label> <input type="text" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " value="<?php echo $title; ?> " /> </p> <p> <input type="checkbox" class="show_icon_options" id="<?php echo $this->get_field_id('show_icon_options'); ?> " name="<?php echo $this->get_field_name('show_icon_options'); ?> " <?php echo $show_icon_options == 'on' ? 'checked' : ''; ?> /> <label for="<?php echo $this->get_field_id('show_icon_options'); ?> "><?php _e("Show icon options", THEME_SLUG); ?> </label> </p> <!-- ICON SELECTION --> <?php $args = array('title_select' => $title_select, 'title_fa' => $title_fa, 'title_img' => $title_img, 'thumb_url' => $thumb_url, 'display_none' => $display_none, 'show_icon_options' => $show_icon_options, '_this' => $this); cws_widget_icon_selection($args); ?> <!-- ICON SELECTION --> <p><input id="<?php echo $this->get_field_id('backlight'); ?> " name="<?php echo $this->get_field_name('backlight'); ?> " type="checkbox" <?php echo isset($backlight) && $backlight == "on" ? "checked" : ''; ?> /> <label for="<?php echo $this->get_field_id('backlight'); ?> "><?php _e('Highlight this widget', THEME_SLUG); ?> </label></p> <?php }
function form($instance) { $title = isset($instance['title']) ? esc_attr($instance['title']) : __('Latest Posts', THEME_SLUG); $category = isset($instance['category']) ? esc_attr($instance['category']) : NULL; $post_count = isset($instance['post_count']) ? absint($instance['post_count']) : 8; $number = isset($instance['number']) ? absint($instance['number']) : 4; $count_chars = isset($instance['count_chars']) ? absint($instance['count_chars']) : 50; $show_date = isset($instance['show_date']) ? (bool) $instance['show_date'] : false; $backlight = isset($instance['backlight']) ? $instance['backlight'] : false; /* ICON VARIABLES */ $title_select = isset($instance['title_select']) ? strval($instance['title_select']) : 'fa'; $title_fa = isset($instance['title_fa']) ? strip_tags($instance['title_fa']) : ''; $title_img = isset($instance['title_img']) ? strval($instance['title_img']) : ''; $display_none = ' style="display:none"'; $thumb_url = $title_img ? '="' . wp_get_attachment_thumb_url($title_img) . '"' : ''; $show_icon_options = isset($instance['show_icon_options']) ? $instance['show_icon_options'] : false; /* ICON VARIABLES */ $cats = get_terms('category'); ?> <p><label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title:', THEME_SLUG); ?> </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> <input type="checkbox" class="show_icon_options" id="<?php echo $this->get_field_id('show_icon_options'); ?> " name="<?php echo $this->get_field_name('show_icon_options'); ?> " <?php echo $show_icon_options == 'on' ? 'checked' : ''; ?> /> <label for="<?php echo $this->get_field_id('show_icon_options'); ?> "><?php _e("Show icon options", THEME_SLUG); ?> </label> </p> <!-- ICON SELECTION --> <?php $args = array('title_select' => $title_select, 'title_fa' => $title_fa, 'title_img' => $title_img, 'thumb_url' => $thumb_url, 'display_none' => $display_none, 'show_icon_options' => $show_icon_options, '_this' => $this); cws_widget_icon_selection($args); ?> <!-- ICON SELECTION --> <p><label for="<?php echo $this->get_field_id('category'); ?> "><?php _e('Category:', THEME_SLUG); ?> </label> <select class="widefat" id="<?php echo $this->get_field_id('category'); ?> " name="<?php echo $this->get_field_name('category'); ?> "> <option value="0" label="<?php _e('All Categories', THEME_SLUG); ?> " /> <?php foreach ($cats as $cat) { echo "<option value='{$cat->term_id}'" . ($cat->term_id == $category ? " selected='selected'" : "") . ">" . $cat->name . "</option>"; } ?> </select> <p><label for="<?php echo $this->get_field_id('number'); ?> "><?php _e('Posts per slide:', THEME_SLUG); ?> </label> <input id="<?php echo $this->get_field_id('number'); ?> " name="<?php echo $this->get_field_name('number'); ?> " type="number" value="<?php echo $number; ?> " size="3" /></p> <p><label for="<?php echo $this->get_field_id('post_count'); ?> "><?php _e('Posts to show:', THEME_SLUG); ?> </label> <input id="<?php echo $this->get_field_id('post_count'); ?> " name="<?php echo $this->get_field_name('post_count'); ?> " type="number" value="<?php echo $post_count; ?> " size="3" /></p> <p><label for="<?php echo $this->get_field_id('count_chars'); ?> "><?php _e('Description length:', THEME_SLUG); ?> </label> <input id="<?php echo $this->get_field_id('count_chars'); ?> " name="<?php echo $this->get_field_name('count_chars'); ?> " type="number" value="<?php echo $count_chars; ?> " size="3" /></p> <p><input class="checkbox" type="checkbox" <?php checked($show_date); ?> id="<?php echo $this->get_field_id('show_date'); ?> " name="<?php echo $this->get_field_name('show_date'); ?> " /> <label for="<?php echo $this->get_field_id('show_date'); ?> "><?php _e('Show post date', THEME_SLUG); ?> </label></p> <p><input id="<?php echo $this->get_field_id('backlight'); ?> " name="<?php echo $this->get_field_name('backlight'); ?> " type="checkbox" <?php echo isset($backlight) && $backlight == "on" ? "checked" : ''; ?> /> <label for="<?php echo $this->get_field_id('backlight'); ?> "><?php _e('Highlight this widget', THEME_SLUG); ?> </label></p> <?php }