function form($instance) { $defaults = array('title' => __('Posts', 'pis'), 'title_link' => '', 'intro' => '', 'post_type' => 'post', 'posts_id' => '', 'author' => '', 'cat' => '', 'tag' => '', 'post_format' => '', 'number' => get_option('posts_per_page'), 'orderby' => 'date', 'order' => 'DESC', 'exclude_current_post' => false, 'post_not_in' => '', 'cat_not_in' => '', 'tag_not_in' => '', 'offset_number' => '', 'post_status' => 'publish', 'post_meta_key' => '', 'post_meta_val' => '', 'ignore_sticky' => false, 'display_title' => true, 'link_on_title' => true, 'arrow' => false, 'display_image' => false, 'image_size' => 'thumbnail', 'image_align' => 'no_change', 'image_before_title' => false, 'side_image_margin' => NULL, 'bottom_image_margin' => NULL, 'excerpt' => 'excerpt', 'exc_length' => 20, 'the_more' => __('Read more…', 'pis'), 'exc_arrow' => false, 'utility_after_title' => false, 'display_author' => false, 'author_text' => __('By', 'pis'), 'linkify_author' => false, 'display_date' => false, 'date_text' => __('Published on', 'pis'), 'linkify_date' => false, 'comments' => false, 'comments_text' => __('Comments:', 'pis'), 'utility_sep' => '|', 'categories' => false, 'categ_text' => __('Category:', 'pis'), 'categ_sep' => ',', 'tags' => false, 'tags_text' => __('Tags:', 'pis'), 'hashtag' => '#', 'tag_sep' => '', 'custom_field' => false, 'custom_field_txt' => '', 'meta' => '', 'custom_field_key' => false, 'custom_field_sep' => ':', 'archive_link' => false, 'link_to' => 'category', 'archive_text' => __('Display all posts', 'pis'), 'nopost_text' => __('No posts yet.', 'pis'), 'container_class' => '', 'list_element' => 'ul', 'remove_bullets' => false, 'margin_unit' => 'px', 'intro_margin' => NULL, 'title_margin' => NULL, 'excerpt_margin' => NULL, 'utility_margin' => NULL, 'categories_margin' => NULL, 'tags_margin' => NULL, 'custom_field_margin' => NULL, 'archive_margin' => NULL, 'noposts_margin' => NULL, 'custom_styles' => '', 'cached' => false, 'cache_time' => ''); $instance = wp_parse_args((array) $instance, $defaults); $ignore_sticky = (bool) $instance['ignore_sticky']; $exclude_current_post = (bool) $instance['exclude_current_post']; $display_title = (bool) $instance['display_title']; $link_on_title = (bool) $instance['link_on_title']; $display_image = (bool) $instance['display_image']; $image_before_title = (bool) $instance['image_before_title']; $arrow = (bool) $instance['arrow']; $exc_arrow = (bool) $instance['exc_arrow']; $utility_after_title = (bool) $instance['utility_after_title']; $display_author = (bool) $instance['display_author']; $linkify_author = (bool) $instance['linkify_author']; $display_date = (bool) $instance['display_date']; $linkify_date = (bool) $instance['linkify_date']; $comments = (bool) $instance['comments']; $categories = (bool) $instance['categories']; $tags = (bool) $instance['tags']; $custom_field = (bool) $instance['custom_field']; $custom_field_key = (bool) $instance['custom_field_key']; $archive_link = (bool) $instance['archive_link']; $remove_bullets = (bool) $instance['remove_bullets']; $cached = (bool) $instance['cached']; ?> <style> .pis-gray-title { background-color: #ddd; padding: 3px 5px; } .pis-column { float: left; width: 31%; margin-right: 2%; } .pis-column-last { float: left; width: 31%; } .pis-alert { color: #777; font-weight: bold; } </style> <div class="pis-column"> <h4 class="pis-gray-title"><?php _e('The title of the widget', 'pis'); ?> </h4> <?php pis_form_input_text(__('Title', 'pis'), $this->get_field_id('title'), $this->get_field_name('title'), esc_attr($instance['title'])); ?> <?php pis_form_input_text(__('Link the title of the widget to this URL', 'pis'), $this->get_field_id('title_link'), $this->get_field_name('title_link'), esc_url($instance['title_link'])); ?> <?php pis_form_textarea(__('Place this text after the title', 'pis'), $this->get_field_id('intro'), $this->get_field_name('intro'), $instance['intro'], $style = 'resize: vertical; width: 100%; height: 80px;', $comment = sprintf(__('Allowed HTML: %s. Other tags will be stripped.', 'pis'), '<code>a</code>, <code>strong</code>, <code>em</code>')); ?> <hr /> <h4 class="pis-gray-title"><?php _e('Posts retrieving', 'pis'); ?> </h4> <?php // ================= Post types $args = array('public' => true); $post_types = (array) get_post_types($args, 'objects', 'and'); $options = array(array('value' => 'any', 'desc' => __('Any', 'pis'))); foreach ($post_types as $post_type) { $options[] = array('value' => $post_type->name, 'desc' => $post_type->labels->singular_name); } pis_form_select(__('Post type', 'pis'), $this->get_field_id('post_type'), $this->get_field_name('post_type'), $options, $instance['post_type']); ?> <?php // ================= Posts ID pis_form_input_text(__('Get these posts exactly', 'pis'), $this->get_field_id('posts_id'), $this->get_field_name('posts_id'), esc_attr($instance['posts_id']), sprintf(__('Insert IDs separated by commas. To easily find the IDs, install %1$sthis plugin%2$s.', 'pis'), '<a href="http://wordpress.org/plugins/reveal-ids-for-wp-admin-25/" target="_blank">', '</a>')); ?> <?php // ================= Author $options = array(array('value' => 'NULL', 'desc' => __('Any', 'pis'))); $authors = (array) get_users('who=authors'); // If set to 'authors', only authors (user level greater than 0) will be returned. foreach ($authors as $author) { $options[] = array('value' => $author->user_nicename, 'desc' => $author->display_name); } pis_form_select(__('Get posts by this author', 'pis'), $this->get_field_id('author'), $this->get_field_name('author'), $options, $instance['author']); ?> <?php // ================= Category pis_form_input_text(__('Get posts with these categories', 'pis'), $this->get_field_id('cat'), $this->get_field_name('cat'), esc_attr($instance['cat']), sprintf(__('Insert slugs separated by commas. To display posts that have all of the categories, use %1$s (a plus) between terms, for example:%2$s%3$s.', 'pis'), '<code>+</code>', '<br />', '<code>staff+news+our-works</code>')); ?> <?php // ================= Tag pis_form_input_text(__('Get posts with these tags', 'pis'), $this->get_field_id('tag'), $this->get_field_name('tag'), esc_attr($instance['tag']), sprintf(__('Insert slugs separated by commas. To display posts that have all of the tags, use %1$s (a plus) between terms, for example:%2$s%3$s.', 'pis'), '<code>+</code>', '<br />', '<code>staff+news+our-works</code>')); ?> <?php // ================= Post format $options = array(array('value' => '', 'desc' => __('Any', 'pis'))); $post_formats = get_terms('post_format'); foreach ($post_formats as $post_format) { $options[] = array('value' => $post_format->slug, 'desc' => $post_format->name); } pis_form_select(__('Get posts with this post format', 'pis'), $this->get_field_id('post_format'), $this->get_field_name('post_format'), $options, $instance['post_format']); ?> <?php // ================= Posts quantity pis_form_input_text(__('Display this number of posts', 'pis'), $this->get_field_id('number'), $this->get_field_name('number'), esc_attr($instance['number']), sprintf(__('The value %s shows all the posts.', 'pis'), '<code>-1</code>')); ?> <?php // ================= Post order by $options = array('none' => array('value' => 'none', 'desc' => __('None', 'pis')), 'id' => array('value' => 'id', 'desc' => __('ID', 'pis')), 'author' => array('value' => 'author', 'desc' => __('Author', 'pis')), 'title' => array('value' => 'title', 'desc' => __('Title', 'pis')), 'name' => array('value' => 'name', 'desc' => __('Name (post slug)', 'pis')), 'date' => array('value' => 'date', 'desc' => __('Date', 'pis')), 'modified' => array('value' => 'modified', 'desc' => __('Modified', 'pis')), 'parent' => array('value' => 'parent', 'desc' => __('Parent', 'pis')), 'rand' => array('value' => 'rand', 'desc' => __('Random', 'pis')), 'comment_count' => array('value' => 'comment_count', 'desc' => __('Comment count', 'pis')), 'menu_order' => array('value' => 'menu_order', 'desc' => __('Menu order', 'pis')), 'meta_value' => array('value' => 'meta_value', 'desc' => __('Meta value', 'pis')), 'meta_value_num' => array('value' => 'meta_value_num', 'desc' => __('Meta value number', 'pis')), 'post__in' => array('value' => 'post__in', 'desc' => __('Preserve ID order', 'pis'))); pis_form_select(__('Order posts by', 'pis'), $this->get_field_id('orderby'), $this->get_field_name('orderby'), $options, $instance['orderby']); ?> <?php // ================= Post order $options = array('asc' => array('value' => 'ASC', 'desc' => __('Ascending', 'pis')), 'desc' => array('value' => 'DESC', 'desc' => __('Descending', 'pis'))); pis_form_select(__('The order will be', 'pis'), $this->get_field_id('order'), $this->get_field_name('order'), $options, $instance['order']); ?> <?php // ================= Number of posts to skip pis_form_input_text(__('Skip this number of posts', 'pis'), $this->get_field_id('offset_number'), $this->get_field_name('offset_number'), esc_attr($instance['offset_number'])); ?> <?php // ================= Post status $options = array(); $statuses = get_post_stati('', 'objects'); foreach ($statuses as $status) { $options[] = array('value' => $status->name, 'desc' => $status->label); } pis_form_select(__('Get posts with this post status', 'pis'), $this->get_field_id('post_status'), $this->get_field_name('post_status'), $options, $instance['post_status']); ?> <?php // ================= Post meta key pis_form_input_text(__('Get post with this meta key', 'pis'), $this->get_field_id('post_meta_key'), $this->get_field_name('post_meta_key'), esc_attr($instance['post_meta_key'])); ?> <?php // ================= Post meta value pis_form_input_text(__('Get post with this meta value', 'pis'), $this->get_field_id('post_meta_val'), $this->get_field_name('post_meta_val'), esc_attr($instance['post_meta_val'])); ?> <?php // ================= Ignore sticky post pis_form_checkbox(__('Ignore sticky posts status', 'pis'), $this->get_field_id('ignore_sticky'), $this->get_field_name('ignore_sticky'), checked($ignore_sticky, true, false), __('Sticky posts are automatically ignored if you set up an author or a taxonomy in this widget.', 'pis')); ?> <hr /> <h4 class="pis-gray-title"><?php _e('Posts exclusion', 'pis'); ?> </h4> <?php // ================= Ignore sticky post pis_form_checkbox(__('Automatically exclude the current post in single post or the current page in single page', 'pis'), $this->get_field_id('exclude_current_post'), $this->get_field_name('exclude_current_post'), checked($exclude_current_post, true, false)); ?> <?php // ================= Exclude posts that have these ids. pis_form_input_text(__('Exclude posts with these IDs', 'pis'), $this->get_field_id('post_not_in'), $this->get_field_name('post_not_in'), esc_attr($instance['post_not_in']), sprintf(__('Insert IDs separated by commas. To easily find the IDs, install %1$sthis plugin%2$s.', 'pis'), '<a href="http://wordpress.org/plugins/reveal-ids-for-wp-admin-25/" target="_blank">', '</a>')); ?> <?php // ================= Exclude posts from categories if (is_array($instance['cat_not_in'])) { $var = implode(',', $instance['cat_not_in']); } else { $var = $instance['cat_not_in']; } pis_form_input_text(__('Exclude posts from these categories', 'pis'), $this->get_field_id('cat_not_in'), $this->get_field_name('cat_not_in'), esc_attr($var), __('Insert IDs separated by commas.', 'pis')); ?> <?php // ================= Exclude posts from tags if (is_array($instance['tag_not_in'])) { $var = implode(',', $instance['tag_not_in']); } else { $var = $instance['tag_not_in']; } pis_form_input_text(__('Exclude posts from these tags', 'pis'), $this->get_field_id('tag_not_in'), $this->get_field_name('tag_not_in'), esc_attr($var), __('Insert IDs separated by commas.', 'pis')); ?> </div> <div class="pis-column"> <h4 class="pis-gray-title"><?php _e('The title of the post', 'pis'); ?> </h4> <?php // ================= Title of the post pis_form_checkbox(__('Display the title of the post', 'pis'), $this->get_field_id('display_title'), $this->get_field_name('display_title'), checked($display_title, true, false)); ?> <?php // ================= Link to the title pis_form_checkbox(__('Link the title to the post', 'pis'), $this->get_field_id('link_on_title'), $this->get_field_name('link_on_title'), checked($link_on_title, true, false)); ?> <?php // ================= Arrow after the title pis_form_checkbox(__('Show an arrow after the title', 'pis'), $this->get_field_id('arrow'), $this->get_field_name('arrow'), checked($arrow, true, false)); ?> <hr /> <h4 class="pis-gray-title"><?php _e('The featured image of the post', 'pis'); ?> </h4> <?php if (!current_theme_supports('post-thumbnails')) { ?> <p class="pis-alert"><?php _e('Your theme does not support the Post Thumbnail feature. No image will be displayed.', 'pis'); ?> </p> <?php } ?> <?php // ================= Featured image pis_form_checkbox(__('Display the featured image of the post', 'pis'), $this->get_field_id('display_image'), $this->get_field_name('display_image'), checked($display_image, true, false)); ?> <?php // ================= Image sizes $options = array(); $sizes = (array) get_intermediate_image_sizes(); foreach ($sizes as $size) { $options[] = array('value' => $size, 'desc' => $size); } pis_form_select(__('The size of the thumbnail will be', 'pis'), $this->get_field_id('image_size'), $this->get_field_name('image_size'), $options, $instance['image_size']); ?> <?php // ================= Image align $options = array('nochange' => array('value' => 'nochange', 'desc' => __('Do not change', 'pis')), 'left' => array('value' => 'left', 'desc' => __('Left', 'pis')), 'right' => array('value' => 'right', 'desc' => __('Right', 'pis')), 'center' => array('value' => 'center', 'desc' => __('Center', 'pis'))); pis_form_select(__('Align the image to', 'pis'), $this->get_field_id('image_align'), $this->get_field_name('image_align'), $options, $instance['image_align']); ?> <p> <em> <?php printf(__('Note that in order to use image sizes different from the WordPress standards, add them to your %3$sfunctions.php%4$s file. See the %1$sCodex%2$s for further information.', 'pis'), '<a href="http://codex.wordpress.org/Function_Reference/add_image_size" target="_blank">', '</a>', '<code>', '</code>'); ?> <?php printf(__('You can also use %1$sa plugin%2$s that could help you in doing it.', 'pis'), '<a href="http://wordpress.org/plugins/simple-image-sizes/" target="_blank">', '</a>'); ?> </em> </p> <?php // ================= Positioning image bfore title pis_form_checkbox(__('Display the image before the title of the post', 'pis'), $this->get_field_id('image_before_title'), $this->get_field_name('image_before_title'), checked($image_before_title, true, false)); ?> <hr /> <h4 class="pis-gray-title"><?php _e('The text of the post', 'pis'); ?> </h4> <?php // ================= Type of text $options = array('full_content' => array('value' => 'full_content', 'desc' => __('The full content', 'pis')), 'rich_content' => array('value' => 'rich_content', 'desc' => __('The rich content', 'pis')), 'content' => array('value' => 'content', 'desc' => __('The simple text', 'pis')), 'more_excerpt' => array('value' => 'more_excerpt', 'desc' => __('The excerpt up to "more" tag', 'pis')), 'excerpt' => array('value' => 'excerpt', 'desc' => __('The excerpt', 'pis')), 'none' => array('value' => 'none', 'desc' => __('Do not show any text', 'pis'))); pis_form_select(__('Display this type of text', 'pis'), $this->get_field_id('excerpt'), $this->get_field_name('excerpt'), $options, $instance['excerpt']); ?> <?php // ================= Excerpt length pis_form_input_text(__('The WordPress generated excerpt length will be (in words)', 'pis'), $this->get_field_id('exc_length'), $this->get_field_name('exc_length'), esc_attr($instance['exc_length'])); ?> <?php // ================= More link text pis_form_input_text(__('Use this text for More link', 'pis'), $this->get_field_id('the_more'), $this->get_field_name('the_more'), esc_attr($instance['the_more'])); ?> <?php // ================= Arrow after the excerpt pis_form_checkbox(__('Display an arrow after the "Read more" link', 'pis'), $this->get_field_id('exc_arrow'), $this->get_field_name('exc_arrow'), checked($exc_arrow, true, false)); ?> <hr /> <h4 class="pis-gray-title"><?php _e('Author, date and comments', 'pis'); ?> </h4> <?php // ================= Author pis_form_checkbox(__('Display the author of the post', 'pis'), $this->get_field_id('display_author'), $this->get_field_name('display_author'), checked($display_author, true, false)); ?> <?php // ================= Author text pis_form_input_text(__('Use this text before author\'s name', 'pis'), $this->get_field_id('author_text'), $this->get_field_name('author_text'), esc_attr($instance['author_text'])); ?> <?php // ================= Author archive pis_form_checkbox(__('Link the author to his archive', 'pis'), $this->get_field_id('linkify_author'), $this->get_field_name('linkify_author'), checked($linkify_author, true, false)); ?> <?php // ================= Date pis_form_checkbox(__('Display the date of the post', 'pis'), $this->get_field_id('display_date'), $this->get_field_name('display_date'), checked($display_date, true, false)); ?> <?php // ================= Date text pis_form_input_text(__('Use this text before date', 'pis'), $this->get_field_id('date_text'), $this->get_field_name('date_text'), esc_attr($instance['date_text'])); ?> <?php // ================= Date link pis_form_checkbox(__('Link the date to the post', 'pis'), $this->get_field_id('linkify_date'), $this->get_field_name('linkify_date'), checked($linkify_date, true, false)); ?> <?php // ================= Number of comments pis_form_checkbox(__('Display the number of comments', 'pis'), $this->get_field_id('comments'), $this->get_field_name('comments'), checked($comments, true, false)); ?> <?php // ================= Comments text pis_form_input_text(__('Use this text before comments number', 'pis'), $this->get_field_id('comments_text'), $this->get_field_name('comments_text'), esc_attr($instance['comments_text'])); ?> <?php // ================= Utility separator pis_form_input_text(__('Use this separator between author, date and comments', 'pis'), $this->get_field_id('utility_sep'), $this->get_field_name('utility_sep'), esc_attr($instance['utility_sep']), __('A space will be added before and after the separator.', 'pis')); ?> <?php // ================= Author pis_form_checkbox(__('Display this section after the title of the post', 'pis'), $this->get_field_id('utility_after_title'), $this->get_field_name('utility_after_title'), checked($utility_after_title, true, false)); ?> </div> <div class="pis-column"> <h4 class="pis-gray-title"><?php _e('The categories of the post', 'pis'); ?> </h4> <?php // ================= Post categories pis_form_checkbox(__('Display the categories of the post', 'pis'), $this->get_field_id('categories'), $this->get_field_name('categories'), checked($categories, true, false)); ?> <?php // ================= Categories text pis_form_input_text(__('Use this text before categories list', 'pis'), $this->get_field_id('categ_text'), $this->get_field_name('categ_text'), esc_attr($instance['categ_text'])); ?> <?php // ================= Categories separator pis_form_input_text(__('Use this separator between categories', 'pis'), $this->get_field_id('categ_sep'), $this->get_field_name('categ_sep'), esc_attr($instance['categ_sep']), __('A space will be added after the separator.', 'pis')); ?> <hr /> <h4 class="pis-gray-title"><?php _e('The tags of the post', 'pis'); ?> </h4> <?php // ================= Post tags pis_form_checkbox(__('Show the tags of the post', 'pis'), $this->get_field_id('tags'), $this->get_field_name('tags'), checked($tags, true, false)); ?> <?php // ================= Tags text pis_form_input_text(__('Use this text before tags list', 'pis'), $this->get_field_id('tags_text'), $this->get_field_name('tags_text'), esc_attr($instance['tags_text'])); ?> <?php // ================= Hashtag pis_form_input_text(__('Use this hashtag', 'pis'), $this->get_field_id('hashtag'), $this->get_field_name('hashtag'), esc_attr($instance['hashtag'])); ?> <?php // ================= Tags separator pis_form_input_text(__('Use this separator between tags', 'pis'), $this->get_field_id('tag_sep'), $this->get_field_name('tag_sep'), esc_attr($instance['tag_sep']), __('A space will be added after the separator.', 'pis')); ?> <hr /> <h4 class="pis-gray-title"><?php _e('The custom field', 'pis'); ?> </h4> <?php // ================= Display custom field pis_form_checkbox(__('Display the custom field of the post', 'pis'), $this->get_field_id('custom_field'), $this->get_field_name('custom_field'), checked($custom_field, true, false)); ?> <?php // ================= Custom fields text pis_form_input_text(__('Use this text before the custom field', 'pis'), $this->get_field_id('custom_field_txt'), $this->get_field_name('custom_field_txt'), esc_attr($instance['custom_field_txt'])); ?> <?php // ================= Which custom field $options = array(); $metas = (array) pis_meta(); foreach ($metas as $meta) { if (!is_protected_meta($meta, 'post')) { $options[] = array('value' => $meta, 'desc' => $meta); } } pis_form_select(__('Display this custom field', 'pis'), $this->get_field_id('meta'), $this->get_field_name('meta'), $options, $instance['meta']); ?> <?php // ================= Custom field key pis_form_checkbox(__('Also display the key of the custom field', 'pis'), $this->get_field_id('custom_field_key'), $this->get_field_name('custom_field_key'), checked($custom_field_key, true, false)); ?> <?php // ================= Custom field separator pis_form_input_text(__('Use this separator between meta key and value', 'pis'), $this->get_field_id('custom_field_sep'), $this->get_field_name('custom_field_sep'), esc_attr($instance['custom_field_sep'])); ?> <hr /> <h4 class="pis-gray-title"><?php _e('The link to the archive', 'pis'); ?> </h4> <?php // ================= Taxonomy archive link pis_form_checkbox(__('Display the link to the taxonomy archive', 'pis'), $this->get_field_id('archive_link'), $this->get_field_name('archive_link'), checked($archive_link, true, false)); ?> <?php // ================= Which taxonomy $options = array('author' => array('value' => 'author', 'desc' => __('Author', 'pis')), 'category' => array('value' => 'category', 'desc' => __('Category', 'pis')), 'tag' => array('value' => 'tag', 'desc' => __('Tag', 'pis'))); $custom_post_types = (array) get_post_types(array('_builtin' => false, 'exclude_from_search' => false), 'objects'); foreach ($custom_post_types as $custom_post_type) { $options[] = array('value' => $custom_post_type->name, 'desc' => sprintf(__('Post type: %s', 'pis'), $custom_post_type->labels->singular_name)); } if ($post_formats) { foreach ($post_formats as $post_format) { $options[] = array('value' => $post_format->slug, 'desc' => sprintf(__('Post format: %s', 'pis'), $post_format->name)); } } pis_form_select(__('Link to the archive of', 'pis'), $this->get_field_id('link_to'), $this->get_field_name('link_to'), $options, $instance['link_to']); ?> <?php // ================= Archive link text pis_form_input_text(__('Use this text for archive link', 'pis'), $this->get_field_id('archive_text'), $this->get_field_name('archive_text'), esc_attr($instance['archive_text']), __('Please, note that if you don\'t select any taxonomy, the link won\'t appear.', 'pis')); ?> <?php // ================= No posts text pis_form_input_text(__('Use this text when there are no posts', 'pis'), $this->get_field_id('nopost_text'), $this->get_field_name('nopost_text'), esc_attr($instance['nopost_text'])); ?> <hr /> <h4 class="pis-gray-title"><?php _e('Extras', 'pis'); ?> </h4> <?php // ================= Container Class pis_form_input_text(__('Add a global container with this CSS class', 'pis'), $this->get_field_id('container_class'), $this->get_field_name('container_class'), esc_attr($instance['container_class']), sprintf(__('The plugin will add a new %s container with this class. You can enter only one class and the name could contain only letters, hyphens and underscores. The new container will enclose all the widget, from the title up to the last line.', 'pis'), '<code>div</code>')); ?> <?php // ================= Type of HTML for list of posts $options = array('ul' => array('value' => 'ul', 'desc' => __('Unordered list', 'pis')), 'ol' => array('value' => 'ol', 'desc' => __('Ordered list', 'pis'))); pis_form_select(__('Use this type of list for the posts', 'pis'), $this->get_field_id('list_element'), $this->get_field_name('list_element'), $options, $instance['list_element']); ?> <?php // ================= Remove bullets and left space pis_form_checkbox(__('Try to remove the bullets and the extra left space from the list elements', 'pis'), $this->get_field_id('remove_bullets'), $this->get_field_name('remove_bullets'), checked($remove_bullets, true, false), sprintf(__('If the plugin doesn\'t remove the bullets and/or the extra left space, you have to %1$sedit your CSS file%2$s manually.', 'pis'), '<a href="' . admin_url('theme-editor.php') . '" target="_blank">', '</a>')); ?> <hr /> <h4 class="pis-gray-title"><?php _e('Cache', 'pis'); ?> </h4> <?php // ================= Cache for the query pis_form_checkbox(__('Use a cache to serve the output', 'pis'), $this->get_field_id('cached'), $this->get_field_name('cached'), checked($cached, true, false), __('This option, if activated, will increase the performance.', 'pis')); ?> <?php // ================= Cache duration pis_form_input_text(__('The cache will be used for (in seconds)', 'pis'), $this->get_field_id('cache_time'), $this->get_field_name('cache_time'), esc_attr($instance['cache_time']), sprintf(__('For example, %1$s for one hour of cache. To reset the cache, enter %2$s and save the widget.', 'pis'), '<code>3600</code>', '<code>0</code>')); ?> </div> <div class="clear"></div> <hr /> <h4 class="pis-gray-title"><?php _e('Elements margins', 'pis'); ?> </h4> <p><em><?php _e('This section defines the margin for each line of the widget. Leave blank if you don\'t want to add any local style.', 'pis'); ?> </em></p> <?php // ================= Margin unit $options = array('px' => array('value' => 'px', 'desc' => 'px'), '%' => array('value' => '%', 'desc' => '%'), 'em' => array('value' => 'em', 'desc' => 'em'), 'rem' => array('value' => 'rem', 'desc' => 'rem')); pis_form_select(__('Unit for margins', 'pis'), $this->get_field_id('margin_unit'), $this->get_field_name('margin_unit'), $options, $instance['margin_unit']); ?> <p><strong><?php printf(__('Enter here only the value without any unit, e.g. enter %1$s if you want a space of 10px or enter %2$s if you don\'t want any space.', 'pis'), '<code>10</code>', '<code>0</code>'); ?> </strong></p> <?php // ================= Margins ?> <div class="pis-column"> <?php pis_form_input_text(__('Introduction margin', 'pis'), $this->get_field_id('intro_margin'), $this->get_field_name('intro_margin'), esc_attr($instance['intro_margin'])); ?> <?php pis_form_input_text(__('Title margin', 'pis'), $this->get_field_id('title_margin'), $this->get_field_name('title_margin'), esc_attr($instance['title_margin'])); ?> <?php pis_form_input_text(__('Left/Right image margin', 'pis'), $this->get_field_id('side_image_margin'), $this->get_field_name('side_image_margin'), esc_attr($instance['side_image_margin'])); ?> <?php pis_form_input_text(__('Bottom image margin', 'pis'), $this->get_field_id('bottom_image_margin'), $this->get_field_name('bottom_image_margin'), esc_attr($instance['bottom_image_margin'])); ?> </div> <div class="pis-column"> <?php pis_form_input_text(__('Excerpt margin', 'pis'), $this->get_field_id('excerpt_margin'), $this->get_field_name('excerpt_margin'), esc_attr($instance['excerpt_margin'])); ?> <?php pis_form_input_text(__('Utility margin', 'pis'), $this->get_field_id('utility_margin'), $this->get_field_name('utility_margin'), esc_attr($instance['utility_margin'])); ?> <?php pis_form_input_text(__('Categories margin', 'pis'), $this->get_field_id('categories_margin'), $this->get_field_name('categories_margin'), esc_attr($instance['categories_margin'])); ?> <?php pis_form_input_text(__('Tags margin', 'pis'), $this->get_field_id('tags_margin'), $this->get_field_name('tags_margin'), esc_attr($instance['tags_margin'])); ?> </div> <div class="pis-column-last"> <?php pis_form_input_text(__('Custom field margin', 'pis'), $this->get_field_id('custom_field_margin'), $this->get_field_name('custom_field_margin'), esc_attr($instance['custom_field_margin'])); ?> <?php pis_form_input_text(__('Archive margin', 'pis'), $this->get_field_id('archive_margin'), $this->get_field_name('archive_margin'), esc_attr($instance['archive_margin'])); ?> <?php pis_form_input_text(__('No-posts margin', 'pis'), $this->get_field_id('noposts_margin'), $this->get_field_name('noposts_margin'), esc_attr($instance['noposts_margin'])); ?> </div> <div class="clear"></div> <hr /> <h4 class="pis-gray-title"><?php _e('Custom styles', 'pis'); ?> </h4> <p><em><?php printf(__('In this field you can add your own styles, for example: %s', 'pis'), '<code>.pis-excerpt { color: green; }</code>'); ?> </em></p> <?php // ================= Custom styles pis_form_textarea(__('Custom styles', 'pis'), $this->get_field_id('custom_styles'), $this->get_field_name('custom_styles'), $instance['custom_styles'], $style = 'resize: vertical; width: 100%; height: 80px;'); ?> <div class="clear"></div> <?php }
/** * Display the options form on admin. * * @see WP_Widget::form() * * @param array $instance Previously saved values from database. * @since 1.0 */ public function form($instance) { $defaults = array('title' => __('Posts', 'posts-in-sidebar'), 'title_link' => '', 'intro' => '', 'post_type' => 'post', 'posts_id' => '', 'author' => '', 'author_in' => '', 'cat' => '', 'tag' => '', 'post_parent_in' => '', 'post_format' => '', 'number' => get_option('posts_per_page'), 'orderby' => 'date', 'order' => 'DESC', 'offset_number' => '', 'post_status' => 'publish', 'post_meta_key' => '', 'post_meta_val' => '', 'search' => NULL, 'ignore_sticky' => false, 'get_from_same_cat' => false, 'title_same_cat' => '', 'relation' => '', 'taxonomy_aa' => '', 'field_aa' => 'slug', 'terms_aa' => '', 'operator_aa' => 'IN', 'relation_a' => '', 'taxonomy_ab' => '', 'field_ab' => 'slug', 'terms_ab' => '', 'operator_ab' => 'IN', 'taxonomy_ba' => '', 'field_ba' => 'slug', 'terms_ba' => '', 'operator_ba' => 'IN', 'relation_b' => '', 'taxonomy_bb' => '', 'field_bb' => 'slug', 'terms_bb' => '', 'operator_bb' => 'IN', 'date_year' => '', 'date_month' => '', 'date_week' => '', 'date_day' => '', 'date_hour' => '', 'date_minute' => '', 'date_second' => '', 'date_after_year' => '', 'date_after_month' => '', 'date_after_day' => '', 'date_before_year' => '', 'date_before_month' => '', 'date_before_day' => '', 'date_inclusive' => false, 'date_column' => '', 'author_not_in' => '', 'exclude_current_post' => false, 'post_not_in' => '', 'cat_not_in' => '', 'tag_not_in' => '', 'post_parent_not_in' => '', 'display_title' => true, 'link_on_title' => true, 'title_tooltip' => __('Permalink to', 'posts-in-sidebar'), 'arrow' => false, 'display_image' => false, 'image_size' => 'thumbnail', 'image_align' => 'no_change', 'image_before_title' => false, 'image_link' => '', 'custom_image_url' => '', 'custom_img_no_thumb' => true, 'excerpt' => 'excerpt', 'exc_length' => 20, 'the_more' => __('Read more…', 'posts-in-sidebar'), 'exc_arrow' => false, 'display_author' => false, 'author_text' => __('By', 'posts-in-sidebar'), 'linkify_author' => false, 'gravatar_display' => false, 'gravatar_size' => 32, 'gravatar_default' => '', 'gravatar_position' => 'next_author', 'display_date' => false, 'date_text' => __('Published on', 'posts-in-sidebar'), 'linkify_date' => false, 'display_mod_date' => false, 'mod_date_text' => __('Modified on', 'posts-in-sidebar'), 'linkify_mod_date' => false, 'comments' => false, 'comments_text' => __('Comments:', 'posts-in-sidebar'), 'linkify_comments' => true, 'utility_sep' => '|', 'utility_after_title' => false, 'categories' => false, 'categ_text' => __('Category:', 'posts-in-sidebar'), 'categ_sep' => ',', 'tags' => false, 'tags_text' => __('Tags:', 'posts-in-sidebar'), 'hashtag' => '#', 'tag_sep' => '', 'display_custom_tax' => false, 'term_hashtag' => '', 'term_sep' => ',', 'custom_field' => false, 'custom_field_txt' => '', 'meta' => '', 'custom_field_key' => false, 'custom_field_sep' => ':', 'archive_link' => false, 'link_to' => 'category', 'tax_name' => '', 'tax_term_name' => '', 'archive_text' => __('Display all posts', 'posts-in-sidebar'), 'nopost_text' => __('No posts yet.', 'posts-in-sidebar'), 'hide_widget' => false, 'margin_unit' => 'px', 'intro_margin' => NULL, 'title_margin' => NULL, 'side_image_margin' => NULL, 'bottom_image_margin' => NULL, 'excerpt_margin' => NULL, 'utility_margin' => NULL, 'categories_margin' => NULL, 'tags_margin' => NULL, 'terms_margin' => NULL, 'custom_field_margin' => NULL, 'archive_margin' => NULL, 'noposts_margin' => NULL, 'custom_styles' => '', 'container_class' => '', 'list_element' => 'ul', 'remove_bullets' => false, 'cached' => false, 'cache_time' => '', 'debug_query' => false, 'debug_params' => false, 'debug_query_number' => false); $instance = wp_parse_args((array) $instance, $defaults); $ignore_sticky = (bool) $instance['ignore_sticky']; $get_from_same_cat = (bool) $instance['get_from_same_cat']; $date_inclusive = (bool) $instance['date_inclusive']; $exclude_current_post = (bool) $instance['exclude_current_post']; $display_title = (bool) $instance['display_title']; $link_on_title = (bool) $instance['link_on_title']; $display_image = (bool) $instance['display_image']; $image_before_title = (bool) $instance['image_before_title']; $arrow = (bool) $instance['arrow']; $custom_img_no_thumb = (bool) $instance['custom_img_no_thumb']; $exc_arrow = (bool) $instance['exc_arrow']; $utility_after_title = (bool) $instance['utility_after_title']; $display_author = (bool) $instance['display_author']; $linkify_author = (bool) $instance['linkify_author']; $gravatar_display = (bool) $instance['gravatar_display']; $display_date = (bool) $instance['display_date']; $linkify_date = (bool) $instance['linkify_date']; $display_mod_date = (bool) $instance['display_mod_date']; $linkify_mod_date = (bool) $instance['linkify_mod_date']; $comments = (bool) $instance['comments']; $linkify_comments = (bool) $instance['linkify_comments']; $categories = (bool) $instance['categories']; $tags = (bool) $instance['tags']; $display_custom_tax = (bool) $instance['display_custom_tax']; $custom_field = (bool) $instance['custom_field']; $custom_field_key = (bool) $instance['custom_field_key']; $archive_link = (bool) $instance['archive_link']; $hide_widget = (bool) $instance['hide_widget']; $remove_bullets = (bool) $instance['remove_bullets']; $cached = (bool) $instance['cached']; $debug_query = (bool) $instance['debug_query']; $debug_params = (bool) $instance['debug_params']; $debug_query_number = (bool) $instance['debug_query_number']; /** * When upgrading from old version, $author, $cat, and $tag could be 'NULL' (as string). * See above for more informations (the long note on function update). * * @since 2.0.3 */ if ('NULL' == $instance['author']) { $instance['author'] = ''; } if ('NULL' == $instance['cat']) { $instance['cat'] = ''; } if ('NULL' == $instance['tag']) { $instance['tag'] = ''; } ?> <!-- Widget title --> <div class="pis-section"> <h4 class="pis-widget-title"><?php _e('The title of the widget', 'posts-in-sidebar'); ?> </h4> <div class="pis-container pis-container-open"> <?php pis_form_input_text(__('Title', 'posts-in-sidebar'), $this->get_field_id('title'), $this->get_field_name('title'), esc_attr($instance['title']), __('From the archive', 'posts-in-sidebar')); ?> <?php pis_form_input_text(__('Link the title of the widget to this URL', 'posts-in-sidebar'), $this->get_field_id('title_link'), $this->get_field_name('title_link'), esc_url(strip_tags($instance['title_link'])), 'http://example.com/readings-series/'); ?> <?php pis_form_textarea(__('Place this text after the title', 'posts-in-sidebar'), $this->get_field_id('intro'), $this->get_field_name('intro'), $instance['intro'], __('These posts are part of my Readings series.', 'posts-in-sidebar'), $style = 'resize: vertical; width: 100%; height: 80px;', $comment = sprintf(__('Allowed HTML: %s. Other tags will be stripped.', 'posts-in-sidebar'), '<code>a</code>, <code>strong</code>, <code>em</code>')); ?> </div> </div> <!-- Getting posts --> <div class="pis-section"> <h4 class="pis-widget-title"><?php _e('Getting posts', 'posts-in-sidebar'); ?> </h4> <div class="pis-container"> <p><em><?php _e('In this section you can define which type of posts you want to retrieve and which taxonomy the plugin will use. Other parameters are available to better define the query.', 'posts-in-sidebar'); ?> </em></p> <p><em><?php printf(__('If a field requires one or more IDs, install %1$sthis plugin%2$s to easily find the IDs.', 'posts-in-sidebar'), '<a href="http://wordpress.org/plugins/reveal-ids-for-wp-admin-25/" target="_blank">', '</a>'); ?> </em></p> <div class="pis-column-container"> <div class="pis-column"> <?php // ================= Post types $args = array('public' => true); $post_types = (array) get_post_types($args, 'objects', 'and'); $options = array(array('value' => 'any', 'desc' => __('Any', 'posts-in-sidebar'))); foreach ($post_types as $post_type) { $options[] = array('value' => $post_type->name, 'desc' => $post_type->labels->singular_name); } pis_form_select(__('Post type', 'posts-in-sidebar'), $this->get_field_id('post_type'), $this->get_field_name('post_type'), $options, $instance['post_type']); ?> <?php // ================= Posts ID pis_form_input_text(__('Get these posts exactly', 'posts-in-sidebar'), $this->get_field_id('posts_id'), $this->get_field_name('posts_id'), esc_attr($instance['posts_id']), '5, 29, 523, 4519', __('Enter IDs separated by commas.', 'posts-in-sidebar')); ?> </div> <div class="pis-column"> <?php // ================= Category pis_form_input_text(__('Get posts with these categories', 'posts-in-sidebar'), $this->get_field_id('cat'), $this->get_field_name('cat'), esc_attr($instance['cat']), __('books, ebooks', 'posts-in-sidebar'), sprintf(__('Enter slugs separated by commas. To display posts that have all of the categories, use %1$s (a plus) between terms, for example:%2$s.', 'posts-in-sidebar'), '<code>+</code>', '<br /><code>staff+news+our-works</code>')); ?> </div> <div class="pis-column"> <?php // ================= Tag pis_form_input_text(__('Get posts with these tags', 'posts-in-sidebar'), $this->get_field_id('tag'), $this->get_field_name('tag'), esc_attr($instance['tag']), __('best-sellers', 'posts-in-sidebar'), sprintf(__('Enter slugs separated by commas. To display posts that have all of the tags, use %1$s (a plus) between terms, for example:%2$s.', 'posts-in-sidebar'), '<code>+</code>', '<br /><code>staff+news+our-works</code>')); ?> </div> </div> <div class="pis-column-container"> <div class="pis-column"> <?php // ================= Author $options = array(array('value' => '', 'desc' => __('Any', 'posts-in-sidebar'))); $authors = (array) get_users('who=authors'); // If set to 'authors', only authors (user level greater than 0) will be returned. foreach ($authors as $author) { $options[] = array('value' => $author->user_nicename, 'desc' => $author->display_name); } pis_form_select(__('Get posts by this author', 'posts-in-sidebar'), $this->get_field_id('author'), $this->get_field_name('author'), $options, $instance['author']); ?> <?php // ================= Multiple authors pis_form_input_text(__('Get posts by these authors', 'posts-in-sidebar'), $this->get_field_id('author_in'), $this->get_field_name('author_in'), esc_attr($instance['author_in']), __('1, 23, 45', 'posts-in-sidebar'), __('Enter IDs separated by commas. Note that if you fill this field, the previous one will be ignored.', 'posts-in-sidebar')); ?> </div> <div class="pis-column"> <?php // ================= Post parent pis_form_input_text(__('Get posts whose parent is in these IDs', 'posts-in-sidebar'), $this->get_field_id('post_parent_in'), $this->get_field_name('post_parent_in'), esc_attr($instance['post_parent_in']), __('2, 5, 12, 14, 20', 'posts-in-sidebar'), __('Enter IDs separated by commas.', 'posts-in-sidebar')); ?> <?php // ================= Post format $options = array(array('value' => '', 'desc' => __('Any', 'posts-in-sidebar'))); $post_formats = get_terms('post_format'); foreach ($post_formats as $post_format) { $options[] = array('value' => $post_format->slug, 'desc' => $post_format->name); } pis_form_select(__('Get posts with this post format', 'posts-in-sidebar'), $this->get_field_id('post_format'), $this->get_field_name('post_format'), $options, $instance['post_format']); ?> <?php // ================= Post status $options = array(array('value' => 'any', 'desc' => 'Any')); $statuses = get_post_stati(array(), 'objects'); foreach ($statuses as $status) { $options[] = array('value' => $status->name, 'desc' => $status->label); } pis_form_select(__('Get posts with this post status', 'posts-in-sidebar'), $this->get_field_id('post_status'), $this->get_field_name('post_status'), $options, $instance['post_status']); ?> </div> <div class="pis-column"> <?php // ================= Post meta key pis_form_input_text(__('Get posts with this meta key', 'posts-in-sidebar'), $this->get_field_id('post_meta_key'), $this->get_field_name('post_meta_key'), esc_attr($instance['post_meta_key']), __('meta-key', 'posts-in-sidebar')); ?> <?php // ================= Post meta value pis_form_input_text(__('Get posts with this meta value', 'posts-in-sidebar'), $this->get_field_id('post_meta_val'), $this->get_field_name('post_meta_val'), esc_attr($instance['post_meta_val']), __('meta-value', 'posts-in-sidebar')); ?> <?php // ================= Search pis_form_input_text(__('Get posts from this search', 'posts-in-sidebar'), $this->get_field_id('search'), $this->get_field_name('search'), esc_attr($instance['search']), __('words to search', 'posts-in-sidebar')); ?> </div> </div> <div class="pis-column-container pis-2col"> <div class="pis-column"> <?php // ================= Posts quantity pis_form_input_text(__('Get this number of posts', 'posts-in-sidebar'), $this->get_field_id('number'), $this->get_field_name('number'), esc_attr($instance['number']), '3', sprintf(__('The value %s shows all the posts.', 'posts-in-sidebar'), '<code>-1</code>')); ?> <?php // ================= Ignore sticky post pis_form_checkbox(__('Do not display sticky posts on top of other posts', 'posts-in-sidebar'), $this->get_field_id('ignore_sticky'), $this->get_field_name('ignore_sticky'), checked($ignore_sticky, true, false), __('If you activate this option, sticky posts will be managed as other posts. Sticky post status will be automatically ignored if you set up an author or a taxonomy in this widget.', 'posts-in-sidebar')); ?> </div> <div class="pis-column"> <?php // ================= Post order by $options = array('none' => array('value' => 'none', 'desc' => __('None', 'posts-in-sidebar')), 'id' => array('value' => 'id', 'desc' => __('ID', 'posts-in-sidebar')), 'author' => array('value' => 'author', 'desc' => __('Author', 'posts-in-sidebar')), 'title' => array('value' => 'title', 'desc' => __('Title', 'posts-in-sidebar')), 'name' => array('value' => 'name', 'desc' => __('Name (post slug)', 'posts-in-sidebar')), 'date' => array('value' => 'date', 'desc' => __('Date', 'posts-in-sidebar')), 'modified' => array('value' => 'modified', 'desc' => __('Modified', 'posts-in-sidebar')), 'parent' => array('value' => 'parent', 'desc' => __('Parent', 'posts-in-sidebar')), 'rand' => array('value' => 'rand', 'desc' => __('Random', 'posts-in-sidebar')), 'comment_count' => array('value' => 'comment_count', 'desc' => __('Comment count', 'posts-in-sidebar')), 'menu_order' => array('value' => 'menu_order', 'desc' => __('Menu order', 'posts-in-sidebar')), 'meta_value' => array('value' => 'meta_value', 'desc' => __('Meta value', 'posts-in-sidebar')), 'meta_value_num' => array('value' => 'meta_value_num', 'desc' => __('Meta value number', 'posts-in-sidebar')), 'post__in' => array('value' => 'post__in', 'desc' => __('Preserve ID order', 'posts-in-sidebar'))); pis_form_select(__('Order posts by', 'posts-in-sidebar'), $this->get_field_id('orderby'), $this->get_field_name('orderby'), $options, $instance['orderby']); ?> <?php // ================= Post order $options = array('asc' => array('value' => 'ASC', 'desc' => __('Ascending', 'posts-in-sidebar')), 'desc' => array('value' => 'DESC', 'desc' => __('Descending', 'posts-in-sidebar'))); pis_form_select(__('The order will be', 'posts-in-sidebar'), $this->get_field_id('order'), $this->get_field_name('order'), $options, $instance['order']); ?> <?php // ================= Number of posts to skip pis_form_input_text(__('Skip this number of posts', 'posts-in-sidebar'), $this->get_field_id('offset_number'), $this->get_field_name('offset_number'), esc_attr($instance['offset_number']), '5'); ?> </div> </div> <hr> <div class="pis-column-container pis-2col"> <div class="pis-column"> <?php // ================= Get posts from same category pis_form_checkbox(__('When on single posts, get posts from the current category', 'posts-in-sidebar'), $this->get_field_id('get_from_same_cat'), $this->get_field_name('get_from_same_cat'), checked($get_from_same_cat, true, false), __('When activated, this function will get posts from the first category of the post, ignoring other parameters like tags, date, post formats, etc. If the post has multiple categories, the plugin will use the first category in the array of categories (the category with the lowest ID). Custom post types are excluded from this feature.', 'posts-in-sidebar')); ?> </div> <div class="pis-column"> <?php // ================= The custom widget title when on single posts pis_form_input_text(__('When on single posts, use this widget title', 'posts-in-sidebar'), $this->get_field_id('title_same_cat'), $this->get_field_name('title_same_cat'), esc_attr($instance['title_same_cat']), __('Posts under %s', 'posts-in-sidebar'), sprintf(__('Use %s to display the name of the category.', 'posts-in-sidebar'), '<code>%s</code>')); ?> </div> </div> <!-- Excluding posts --> <div class="pis-section"> <h4 class="pis-widget-title"><?php _e('Excluding posts', 'posts-in-sidebar'); ?> </h4> <div class="pis-container"> <p><em><?php _e('Define here which posts must be excluded from the query.', 'posts-in-sidebar'); ?> </em></p> <p><em><?php printf(__('If a field requires one or more IDs, install %1$sthis plugin%2$s to easily find the IDs.', 'posts-in-sidebar'), '<a href="http://wordpress.org/plugins/reveal-ids-for-wp-admin-25/" target="_blank">', '</a>'); ?> </em></p> <div class="pis-column-container"> <div class="pis-column"> <?php // ================= Exclude posts by these authors if (is_array($instance['author_not_in'])) { $var = implode(',', $instance['author_not_in']); } else { $var = $instance['author_not_in']; } pis_form_input_text(__('Exclude posts by these authors', 'posts-in-sidebar'), $this->get_field_id('author_not_in'), $this->get_field_name('author_not_in'), esc_attr($var), '1, 23, 45', __('Enter IDs separated by commas.', 'posts-in-sidebar')); ?> <?php // ================= Exclude posts from categories if (is_array($instance['cat_not_in'])) { $var = implode(',', $instance['cat_not_in']); } else { $var = $instance['cat_not_in']; } pis_form_input_text(__('Exclude posts from these categories', 'posts-in-sidebar'), $this->get_field_id('cat_not_in'), $this->get_field_name('cat_not_in'), esc_attr($var), '3, 31', __('Enter IDs separated by commas.', 'posts-in-sidebar')); ?> </div> <div class="pis-column"> <?php // ================= Exclude posts from tags if (is_array($instance['tag_not_in'])) { $var = implode(',', $instance['tag_not_in']); } else { $var = $instance['tag_not_in']; } pis_form_input_text(__('Exclude posts from these tags', 'posts-in-sidebar'), $this->get_field_id('tag_not_in'), $this->get_field_name('tag_not_in'), esc_attr($var), '7, 11', __('Enter IDs separated by commas.', 'posts-in-sidebar')); ?> <?php // ================= Exclude posts that have these ids. pis_form_input_text(__('Exclude posts with these IDs', 'posts-in-sidebar'), $this->get_field_id('post_not_in'), $this->get_field_name('post_not_in'), esc_attr($instance['post_not_in']), '5, 29, 523, 4519', __('Enter IDs separated by commas.', 'posts-in-sidebar')); ?> </div> <div class="pis-column"> <?php // ================= Exclude posts whose parent is in these IDs. pis_form_input_text(__('Exclude posts whose parent is in these IDs', 'posts-in-sidebar'), $this->get_field_id('post_parent_not_in'), $this->get_field_name('post_parent_not_in'), esc_attr($instance['post_parent_not_in']), '5, 29, 523, 4519', __('Enter IDs separated by commas.', 'posts-in-sidebar')); ?> <?php // ================= Exclude current post pis_form_checkbox(__('Automatically exclude the current post in single post or the current page in single page', 'posts-in-sidebar'), $this->get_field_id('exclude_current_post'), $this->get_field_name('exclude_current_post'), checked($exclude_current_post, true, false)); ?> </div> </div> </div> </div> <!-- Custom taxonomy query --> <div class="pis-section pis-2col"> <h4 class="pis-widget-title"><?php _e('Custom taxonomy query', 'posts-in-sidebar'); ?> </h4> <div class="pis-container"> <p><em><?php _e('This section lets you retrieve posts from any taxonomy (category, tags, and custom taxonomies). If you want to use only one taxonomy, use the "Taxonomy A1" field. If you have to put in relation two taxonomies (e.g., display posts that are in the "quotes" category but not in the "wisdom" tag), then use also the "Taxonomy B1" field. If you have to put in relation more taxonomies, start using also the "A2" and "B2" fields (e.g., display posts that are in the "quotes" category [A1] OR both have the "Quote" post format [B1] AND are in the "wisdom" category [B2]).', 'posts-in-sidebar'); ?> </em></p> <p><em><?php printf(__('If a field requires one or more IDs, install %1$sthis plugin%2$s to easily find the IDs.', 'posts-in-sidebar'), '<a href="http://wordpress.org/plugins/reveal-ids-for-wp-admin-25/" target="_blank">', '</a>'); ?> </em></p> <div class="pis-column-container"> <div class="pis-column"> <?php // ================= Taxonomy relation between aa and bb $options = array('empty' => array('value' => '', 'desc' => ''), 'and' => array('value' => 'AND', 'desc' => 'AND'), 'or' => array('value' => 'OR', 'desc' => 'OR')); pis_form_select(__('Relation between Column A and Column B', 'posts-in-sidebar'), $this->get_field_id('relation'), $this->get_field_name('relation'), $options, $instance['relation'], __('The logical relationship between each inner taxonomy array when there is more than one. Do not use with a single inner taxonomy array.', 'posts-in-sidebar')); ?> </div> </div> <hr /> <div class="pis-column-container"> <div class="pis-column"> <h4 class="pis-title-center"><?php _e('Column A', 'posts-in-sidebar'); ?> </h4> <?php // ================= Taxonomy aa pis_form_input_text(sprintf(__('%1$sTaxonomy A1%2$s', 'posts-in-sidebar'), '<strong>', '</strong>'), $this->get_field_id('taxonomy_aa'), $this->get_field_name('taxonomy_aa'), esc_attr($instance['taxonomy_aa']), __('category', 'posts-in-sidebar'), __('Enter the slug of the taxonomy.', 'posts-in-sidebar')); ?> <?php // ================= Field aa $options = array('term_id' => array('value' => 'term_id', 'desc' => __('Term ID', 'posts-in-sidebar')), 'slug' => array('value' => 'slug', 'desc' => __('Slug', 'posts-in-sidebar')), 'name' => array('value' => 'name', 'desc' => __('Name', 'posts-in-sidebar'))); pis_form_select(__('Field', 'posts-in-sidebar'), $this->get_field_id('field_aa'), $this->get_field_name('field_aa'), $options, $instance['field_aa'], __('Select taxonomy term by this field.', 'posts-in-sidebar')); ?> <?php // ================= Terms aa pis_form_input_text(__('Terms', 'posts-in-sidebar'), $this->get_field_id('terms_aa'), $this->get_field_name('terms_aa'), esc_attr($instance['terms_aa']), __('gnu-linux,kde', 'posts-in-sidebar'), __('Enter terms, separated by comma.', 'posts-in-sidebar')); ?> <?php // ================= Operator aa $options = array('in' => array('value' => 'IN', 'desc' => 'IN'), 'not_in' => array('value' => 'NOT IN', 'desc' => 'NOT IN'), 'and' => array('value' => 'AND', 'desc' => 'AND')); pis_form_select(__('Operator', 'posts-in-sidebar'), $this->get_field_id('operator_aa'), $this->get_field_name('operator_aa'), $options, $instance['operator_aa'], __('Operator to test for terms.', 'posts-in-sidebar')); ?> <hr /> <?php // ================= Taxonomy relation between aa and ab $options = array('empty' => array('value' => '', 'desc' => ''), 'and' => array('value' => 'AND', 'desc' => 'AND'), 'or' => array('value' => 'OR', 'desc' => 'OR')); pis_form_select(__('Relation between A1 and A2 taxonomies', 'posts-in-sidebar'), $this->get_field_id('relation_a'), $this->get_field_name('relation_a'), $options, $instance['relation_a']); ?> <hr /> <?php // ================= Taxonomy ab pis_form_input_text(sprintf(__('%1$sTaxonomy A2%2$s', 'posts-in-sidebar'), '<strong>', '</strong>'), $this->get_field_id('taxonomy_ab'), $this->get_field_name('taxonomy_ab'), esc_attr($instance['taxonomy_ab']), __('movie-genre', 'posts-in-sidebar'), __('Enter the slug of the taxonomy.', 'posts-in-sidebar')); ?> <?php // ================= Field ab $options = array('term_id' => array('value' => 'term_id', 'desc' => __('Term ID', 'posts-in-sidebar')), 'slug' => array('value' => 'slug', 'desc' => __('Slug', 'posts-in-sidebar')), 'name' => array('value' => 'name', 'desc' => __('Name', 'posts-in-sidebar'))); pis_form_select(__('Field', 'posts-in-sidebar'), $this->get_field_id('field_ab'), $this->get_field_name('field_ab'), $options, $instance['field_ab'], __('Select taxonomy term by this field.', 'posts-in-sidebar')); ?> <?php // ================= Terms ab pis_form_input_text(__('Terms', 'posts-in-sidebar'), $this->get_field_id('terms_ab'), $this->get_field_name('terms_ab'), esc_attr($instance['terms_ab']), __('action,sci-fi', 'posts-in-sidebar'), __('Enter terms, separated by comma.', 'posts-in-sidebar')); ?> <?php // ================= Operator ab $options = array('in' => array('value' => 'IN', 'desc' => 'IN'), 'not_in' => array('value' => 'NOT IN', 'desc' => 'NOT IN'), 'and' => array('value' => 'AND', 'desc' => 'AND')); pis_form_select(__('Operator', 'posts-in-sidebar'), $this->get_field_id('operator_ab'), $this->get_field_name('operator_ab'), $options, $instance['operator_ab'], __('Operator to test for terms.', 'posts-in-sidebar')); ?> </div> <div class="pis-column"> <h4 class="pis-title-center"><?php _e('Column B', 'posts-in-sidebar'); ?> </h4> <?php // ================= Taxonomy ba pis_form_input_text(sprintf(__('%1$sTaxonomy B1%2$s', 'posts-in-sidebar'), '<strong>', '</strong>'), $this->get_field_id('taxonomy_ba'), $this->get_field_name('taxonomy_ba'), esc_attr($instance['taxonomy_ba']), __('post_tag', 'posts-in-sidebar'), __('Enter the slug of the taxonomy.', 'posts-in-sidebar')); ?> <?php // ================= Field ba $options = array('term_id' => array('value' => 'term_id', 'desc' => __('Term ID', 'posts-in-sidebar')), 'slug' => array('value' => 'slug', 'desc' => __('Slug', 'posts-in-sidebar')), 'name' => array('value' => 'name', 'desc' => __('Name', 'posts-in-sidebar'))); pis_form_select(__('Field', 'posts-in-sidebar'), $this->get_field_id('field_ba'), $this->get_field_name('field_ba'), $options, $instance['field_ba'], __('Select taxonomy term by this field.', 'posts-in-sidebar')); ?> <?php // ================= Terms ba pis_form_input_text(__('Terms', 'posts-in-sidebar'), $this->get_field_id('terms_ba'), $this->get_field_name('terms_ba'), esc_attr($instance['terms_ba']), __('system,apache', 'posts-in-sidebar'), __('Enter terms, separated by comma.', 'posts-in-sidebar')); ?> <?php // ================= Operator ba $options = array('in' => array('value' => 'IN', 'desc' => 'IN'), 'not_in' => array('value' => 'NOT IN', 'desc' => 'NOT IN'), 'and' => array('value' => 'AND', 'desc' => 'AND')); pis_form_select(__('Operator', 'posts-in-sidebar'), $this->get_field_id('operator_ba'), $this->get_field_name('operator_ba'), $options, $instance['operator_ba'], __('Operator to test for terms.', 'posts-in-sidebar')); ?> <hr /> <?php // ================= Taxonomy relation between ba and bb $options = array('empty' => array('value' => '', 'desc' => ''), 'and' => array('value' => 'AND', 'desc' => 'AND'), 'or' => array('value' => 'OR', 'desc' => 'OR')); pis_form_select(__('Relation between B1 and B2 taxonomies', 'posts-in-sidebar'), $this->get_field_id('relation_b'), $this->get_field_name('relation_b'), $options, $instance['relation_b']); ?> <hr /> <?php // ================= Taxonomy bb pis_form_input_text(sprintf(__('%1$sTaxonomy B2%2$s', 'posts-in-sidebar'), '<strong>', '</strong>'), $this->get_field_id('taxonomy_bb'), $this->get_field_name('taxonomy_bb'), esc_attr($instance['taxonomy_bb']), __('post_format', 'posts-in-sidebar'), __('Enter the slug of the taxonomy.', 'posts-in-sidebar')); ?> <?php // ================= Field bb $options = array('term_id' => array('value' => 'term_id', 'desc' => __('Term ID', 'posts-in-sidebar')), 'slug' => array('value' => 'slug', 'desc' => __('Slug', 'posts-in-sidebar')), 'name' => array('value' => 'name', 'desc' => __('Name', 'posts-in-sidebar'))); pis_form_select(__('Field', 'posts-in-sidebar'), $this->get_field_id('field_bb'), $this->get_field_name('field_bb'), $options, $instance['field_bb'], __('Select taxonomy term by this field.', 'posts-in-sidebar')); ?> <?php // ================= Terms bb pis_form_input_text(__('Terms', 'posts-in-sidebar'), $this->get_field_id('terms_bb'), $this->get_field_name('terms_bb'), esc_attr($instance['terms_bb']), __('post-format-quote', 'posts-in-sidebar'), __('Enter terms, separated by comma.', 'posts-in-sidebar')); ?> <?php // ================= Operator bb $options = array('in' => array('value' => 'IN', 'desc' => 'IN'), 'not_in' => array('value' => 'NOT IN', 'desc' => 'NOT IN'), 'and' => array('value' => 'AND', 'desc' => 'AND')); pis_form_select(__('Operator', 'posts-in-sidebar'), $this->get_field_id('operator_bb'), $this->get_field_name('operator_bb'), $options, $instance['operator_bb'], __('Operator to test for terms.', 'posts-in-sidebar')); ?> </div> </div> </div> </div> <!-- Date query --> <div class="pis-section pis-2col"> <h4 class="pis-widget-title"><?php _e('Date query', 'posts-in-sidebar'); ?> </h4> <div class="pis-container"> <p><em><?php _e('Define the date period within posts are published.', 'posts-in-sidebar'); ?> </em></p> <div class="pis-column-container"> <div class="pis-column"> <?php pis_form_input_text(__('Year', 'posts-in-sidebar'), $this->get_field_id('date_year'), $this->get_field_name('date_year'), esc_attr($instance['date_year']), '2015', __('4 digits year (e.g. 2015).', 'posts-in-sidebar')); ?> <?php pis_form_input_text(__('Month', 'posts-in-sidebar'), $this->get_field_id('date_month'), $this->get_field_name('date_month'), esc_attr($instance['date_month']), '06', __('Month number (from 1 to 12).', 'posts-in-sidebar')); ?> <?php pis_form_input_text(__('Week', 'posts-in-sidebar'), $this->get_field_id('date_week'), $this->get_field_name('date_week'), esc_attr($instance['date_week']), '32', __('Week of the year (from 0 to 53).', 'posts-in-sidebar')); ?> <?php pis_form_input_text(__('Day', 'posts-in-sidebar'), $this->get_field_id('date_day'), $this->get_field_name('date_day'), esc_attr($instance['date_day']), '12', __('Day of the month (from 1 to 31).', 'posts-in-sidebar')); ?> </div> <div class="pis-column"> <?php pis_form_input_text(__('Hour', 'posts-in-sidebar'), $this->get_field_id('date_hour'), $this->get_field_name('date_hour'), esc_attr($instance['date_hour']), '09', __('Hour (from 0 to 23).', 'posts-in-sidebar')); ?> <?php pis_form_input_text(__('Minute', 'posts-in-sidebar'), $this->get_field_id('date_minute'), $this->get_field_name('date_minute'), esc_attr($instance['date_minute']), '24', __('Minute (from 0 to 59).', 'posts-in-sidebar')); ?> <?php pis_form_input_text(__('Second', 'posts-in-sidebar'), $this->get_field_id('date_second'), $this->get_field_name('date_second'), esc_attr($instance['date_second']), '32', __('Second (from 0 to 59).', 'posts-in-sidebar')); ?> </div> </div> <div class="pis-column-container"> <div class="pis-column"> <h5 class="pis-title-center"><?php _e('Get posts after this date', 'posts-in-sidebar'); ?> </h5> <?php pis_form_input_text(__('Year', 'posts-in-sidebar'), $this->get_field_id('date_after_year'), $this->get_field_name('date_after_year'), esc_attr($instance['date_after_year']), '2011', __('Accepts any four-digit year.', 'posts-in-sidebar')); ?> <?php pis_form_input_text(__('Month', 'posts-in-sidebar'), $this->get_field_id('date_after_month'), $this->get_field_name('date_after_month'), esc_attr($instance['date_after_month']), '10', __('The month of the year. Accepts numbers 1-12.', 'posts-in-sidebar')); ?> <?php pis_form_input_text(__('Day', 'posts-in-sidebar'), $this->get_field_id('date_after_day'), $this->get_field_name('date_after_day'), esc_attr($instance['date_after_day']), '10', __('The day of the month. Accepts numbers 1-31.', 'posts-in-sidebar')); ?> </div> <div class="pis-column"> <h5 class="pis-title-center"><?php _e('Get posts before this date', 'posts-in-sidebar'); ?> </h5> <?php pis_form_input_text(__('Year', 'posts-in-sidebar'), $this->get_field_id('date_before_year'), $this->get_field_name('date_before_year'), esc_attr($instance['date_before_year']), '2011', __('Accepts any four-digit year.', 'posts-in-sidebar')); ?> <?php pis_form_input_text(__('Month', 'posts-in-sidebar'), $this->get_field_id('date_before_month'), $this->get_field_name('date_before_month'), esc_attr($instance['date_before_month']), '10', __('The month of the year. Accepts numbers 1-12.', 'posts-in-sidebar')); ?> <?php pis_form_input_text(__('Day', 'posts-in-sidebar'), $this->get_field_id('date_before_day'), $this->get_field_name('date_before_day'), esc_attr($instance['date_before_day']), '10', __('The day of the month. Accepts numbers 1-31.', 'posts-in-sidebar')); ?> </div> </div> <div class="pis-column-container"> <h5 class="pis-title-center"><?php _e('Other options', 'posts-in-sidebar'); ?> </h5> <div class="pis-column"> <?php pis_form_checkbox(__('Inclusive', 'posts-in-sidebar'), $this->get_field_id('date_inclusive'), $this->get_field_name('date_inclusive'), checked($date_inclusive, true, false), __('For after/before, whether exact value should be matched or not', 'posts-in-sidebar')); ?> </div> <div class="pis-column"> <?php $options = array('empty' => array('value' => '', 'desc' => ''), 'post_date' => array('value' => 'post_date', 'desc' => __('Post date', 'posts-in-sidebar')), 'post_date_gmt' => array('value' => 'post_date_gmt', 'desc' => __('Post date GMT', 'posts-in-sidebar')), 'post_modified' => array('value' => 'post_modified', 'desc' => __('Post modified', 'posts-in-sidebar')), 'post_modified_gmt' => array('value' => 'post_modified_gmt', 'desc' => __('Post modified GMT', 'posts-in-sidebar'))); pis_form_select(__('Column', 'posts-in-sidebar'), $this->get_field_id('date_column'), $this->get_field_name('date_column'), $options, $instance['date_column'], __('Column to query against.', 'posts-in-sidebar')); ?> </div> </div> </div> </div> </div> </div> <!-- Displaying posts --> <div class="pis-section"> <h4 class="pis-widget-title"><?php _e('Displaying posts', 'posts-in-sidebar'); ?> </h4> <div class="pis-container"> <p><em><?php _e('Define here which elements you want to display in the widget.', 'posts-in-sidebar'); ?> </em></p> <div class="pis-section pis-2col"> <div class="pis-column-container"> <div class="pis-column"> <h4><?php _e('The title of the post', 'posts-in-sidebar'); ?> </h4> <?php // ================= Title of the post pis_form_checkbox(__('Display the title of the post', 'posts-in-sidebar'), $this->get_field_id('display_title'), $this->get_field_name('display_title'), checked($display_title, true, false)); ?> <?php // ================= Link to the title pis_form_checkbox(__('Link the title to the post', 'posts-in-sidebar'), $this->get_field_id('link_on_title'), $this->get_field_name('link_on_title'), checked($link_on_title, true, false)); ?> <?php // ================= Title tooltip pis_form_input_text(__('Use this text in the tooltip', 'posts-in-sidebar'), $this->get_field_id('title_tooltip'), $this->get_field_name('title_tooltip'), esc_attr($instance['title_tooltip']), '', __('The title of the post will be added after this text. Also note that this text will be used for the image tooltip.', 'posts-in-sidebar')); ?> <?php // ================= Arrow after the title pis_form_checkbox(__('Show an arrow after the title', 'posts-in-sidebar'), $this->get_field_id('arrow'), $this->get_field_name('arrow'), checked($arrow, true, false)); ?> </div> <div class="pis-column"> <h4><?php _e('The text of the post', 'posts-in-sidebar'); ?> </h4> <?php // ================= Type of text $options = array('full_content' => array('value' => 'full_content', 'desc' => __('The full content', 'posts-in-sidebar')), 'rich_content' => array('value' => 'rich_content', 'desc' => __('The rich content', 'posts-in-sidebar')), 'content' => array('value' => 'content', 'desc' => __('The simple text', 'posts-in-sidebar')), 'more_excerpt' => array('value' => 'more_excerpt', 'desc' => __('The excerpt up to "more" tag', 'posts-in-sidebar')), 'excerpt' => array('value' => 'excerpt', 'desc' => __('The excerpt', 'posts-in-sidebar')), 'only_read_more' => array('value' => 'only_read_more', 'desc' => __('Display only the Read more link', 'posts-in-sidebar')), 'none' => array('value' => 'none', 'desc' => __('Do not show any text', 'posts-in-sidebar'))); pis_form_select(__('Display this type of text', 'posts-in-sidebar'), $this->get_field_id('excerpt'), $this->get_field_name('excerpt'), $options, $instance['excerpt']); ?> <?php // ================= Excerpt length pis_form_input_text(__('The WordPress generated excerpt length will be (in words)', 'posts-in-sidebar'), $this->get_field_id('exc_length'), $this->get_field_name('exc_length'), esc_attr($instance['exc_length']), '20'); ?> <?php // ================= More link text pis_form_input_text(__('Use this text for More link', 'posts-in-sidebar'), $this->get_field_id('the_more'), $this->get_field_name('the_more'), esc_attr($instance['the_more']), __('Read more…', 'posts-in-sidebar')); ?> <?php // ================= Arrow after the excerpt pis_form_checkbox(__('Display an arrow after the "Read more" link', 'posts-in-sidebar'), $this->get_field_id('exc_arrow'), $this->get_field_name('exc_arrow'), checked($exc_arrow, true, false)); ?> </div> </div> </div> <div class="pis-section pis-2col"> <h4 class="pis-widget-title"><?php _e('The featured image of the post', 'posts-in-sidebar'); ?> </h4> <div class="pis-container"> <div class="pis-column-container"> <div class="pis-column"> <?php if (!current_theme_supports('post-thumbnails')) { ?> <p class="pis-alert"><?php _e('Your theme does not support the Post Thumbnail feature. No image will be displayed.', 'posts-in-sidebar'); ?> </p> <?php } ?> <?php // ================= Featured image pis_form_checkbox(__('Display the featured image of the post', 'posts-in-sidebar'), $this->get_field_id('display_image'), $this->get_field_name('display_image'), checked($display_image, true, false)); ?> <?php // ================= Image sizes $options = array(); $sizes = (array) get_intermediate_image_sizes(); $sizes[] = 'full'; foreach ($sizes as $size) { $options[] = array('value' => $size, 'desc' => $size); } pis_form_select(__('The size of the thumbnail will be', 'posts-in-sidebar'), $this->get_field_id('image_size'), $this->get_field_name('image_size'), $options, $instance['image_size']); ?> <?php // ================= Image align $options = array('nochange' => array('value' => 'nochange', 'desc' => __('Do not change', 'posts-in-sidebar')), 'left' => array('value' => 'left', 'desc' => __('Left', 'posts-in-sidebar')), 'right' => array('value' => 'right', 'desc' => __('Right', 'posts-in-sidebar')), 'center' => array('value' => 'center', 'desc' => __('Center', 'posts-in-sidebar'))); pis_form_select(__('Align the image to', 'posts-in-sidebar'), $this->get_field_id('image_align'), $this->get_field_name('image_align'), $options, $instance['image_align']); ?> <p> <em> <?php printf(__('Note that in order to use image sizes different from the WordPress standards, add them to your theme\'s %3$sfunctions.php%4$s file. See the %1$sCodex%2$s for further information.', 'posts-in-sidebar'), '<a href="http://codex.wordpress.org/Function_Reference/add_image_size" target="_blank">', '</a>', '<code>', '</code>'); ?> <?php printf(__('You can also use %1$sa plugin%2$s that could help you in doing it.', 'posts-in-sidebar'), '<a href="http://wordpress.org/plugins/simple-image-sizes/" target="_blank">', '</a>'); ?> </em> </p> <?php // ================= Positioning image before title pis_form_checkbox(__('Display the image before the title of the post', 'posts-in-sidebar'), $this->get_field_id('image_before_title'), $this->get_field_name('image_before_title'), checked($image_before_title, true, false)); ?> <?php // ================= Image link pis_form_input_text(__('Link the image to this URL', 'posts-in-sidebar'), $this->get_field_id('image_link'), $this->get_field_name('image_link'), esc_url(strip_tags($instance['image_link'])), 'http://example.com/mypage', __('By default the featured image is linked to the post. Use this field to link the image to a URL of your choice. Please, note that every featured image of this widget will be linked to the same URL.', 'posts-in-sidebar')); ?> </div> <div class="pis-column"> <h4><?php _e('Customized featured image', 'posts-in-sidebar'); ?> </h4> <?php // ================= Custom image URL pis_form_input_text(__('Use this image instead of the standard featured image', 'posts-in-sidebar'), $this->get_field_id('custom_image_url'), $this->get_field_name('custom_image_url'), esc_url(strip_tags($instance['custom_image_url'])), 'http://example.com/image.jpg', __('Paste here the URL of the image. Note that the same image will be used for all the posts in the widget, unless you active the checkbox below.', 'posts-in-sidebar')); ?> <?php // ================= Use custom image URL only if the post thumbnail is not defined. pis_form_checkbox(__('Use custom image URL only if the post has not a featured image.', 'posts-in-sidebar'), $this->get_field_id('custom_img_no_thumb'), $this->get_field_name('custom_img_no_thumb'), checked($custom_img_no_thumb, true, false)); ?> </div> </div> </div> </div> <div class="pis-section"> <h4 class="pis-widget-title"><?php _e('Author, date and comments', 'posts-in-sidebar'); ?> </h4> <div class="pis-container"> <div class="pis-column-container"> <div class="pis-column"> <?php // ================= Author pis_form_checkbox(__('Display the author of the post', 'posts-in-sidebar'), $this->get_field_id('display_author'), $this->get_field_name('display_author'), checked($display_author, true, false)); ?> <?php // ================= Author text pis_form_input_text(__('Use this text before author\'s name', 'posts-in-sidebar'), $this->get_field_id('author_text'), $this->get_field_name('author_text'), esc_attr($instance['author_text']), __('By', 'posts-in-sidebar')); ?> <?php // ================= Author archive pis_form_checkbox(__('Link the author to his archive', 'posts-in-sidebar'), $this->get_field_id('linkify_author'), $this->get_field_name('linkify_author'), checked($linkify_author, true, false)); ?> </div> <div class="pis-column"> <?php // ================= Date pis_form_checkbox(__('Display the date of the post', 'posts-in-sidebar'), $this->get_field_id('display_date'), $this->get_field_name('display_date'), checked($display_date, true, false)); ?> <?php // ================= Date text pis_form_input_text(__('Use this text before date', 'posts-in-sidebar'), $this->get_field_id('date_text'), $this->get_field_name('date_text'), esc_attr($instance['date_text']), __('Published on', 'posts-in-sidebar')); ?> <?php // ================= Date link pis_form_checkbox(__('Link the date to the post', 'posts-in-sidebar'), $this->get_field_id('linkify_date'), $this->get_field_name('linkify_date'), checked($linkify_date, true, false)); ?> </div> <div class="pis-column"> <?php // ================= Number of comments pis_form_checkbox(__('Display the number of comments', 'posts-in-sidebar'), $this->get_field_id('comments'), $this->get_field_name('comments'), checked($comments, true, false)); ?> <?php // ================= Comments text pis_form_input_text(__('Use this text before comments', 'posts-in-sidebar'), $this->get_field_id('comments_text'), $this->get_field_name('comments_text'), esc_attr($instance['comments_text']), __('Comments:', 'posts-in-sidebar')); ?> <?php // ================= Comments link pis_form_checkbox(__('Link the comments to post\'s comments', 'posts-in-sidebar'), $this->get_field_id('linkify_comments'), $this->get_field_name('linkify_comments'), checked($linkify_comments, true, false)); ?> </div> </div> <div class="pis-column-container"> <div class="pis-column"> <?php // ================= Author gravatar pis_form_checkbox(__('Display author\'s Gravatar', 'posts-in-sidebar'), $this->get_field_id('gravatar_display'), $this->get_field_name('gravatar_display'), checked($gravatar_display, true, false), '', 'pis-gravatar'); ?> <?php // ================= Gravatar size pis_form_input_text(__('Gravatar size', 'posts-in-sidebar'), $this->get_field_id('gravatar_size'), $this->get_field_name('gravatar_size'), esc_attr($instance['gravatar_size']), '32'); ?> <?php // ================= Gravatar default image pis_form_input_text(__('URL of the default Gravatar image', 'posts-in-sidebar'), $this->get_field_id('gravatar_default'), $this->get_field_name('gravatar_default'), esc_attr($instance['gravatar_default']), 'http://example.com/image.jpg'); ?> <?php // ================= Gravatar position $options = array('next_title' => array('value' => 'next_title', 'desc' => __('Next to the post title', 'posts-in-sidebar')), 'next_post' => array('value' => 'next_post', 'desc' => __('Next to the post content', 'posts-in-sidebar')), 'next_author' => array('value' => 'next_author', 'desc' => __('Next to the author name', 'posts-in-sidebar'))); pis_form_select(__('Gravatar position', 'posts-in-sidebar'), $this->get_field_id('gravatar_position'), $this->get_field_name('gravatar_position'), $options, $instance['gravatar_position']); ?> </div> <div class="pis-column"> <?php // ================= Modification Date pis_form_checkbox(__('Display the modification date of the post', 'posts-in-sidebar'), $this->get_field_id('display_mod_date'), $this->get_field_name('display_mod_date'), checked($display_mod_date, true, false)); ?> <?php // ================= Modification Date text pis_form_input_text(__('Use this text before modification date', 'posts-in-sidebar'), $this->get_field_id('mod_date_text'), $this->get_field_name('mod_date_text'), esc_attr($instance['mod_date_text']), __('Modified on', 'posts-in-sidebar')); ?> <?php // ================= Modification Date link pis_form_checkbox(__('Link the modification date to the post', 'posts-in-sidebar'), $this->get_field_id('linkify_mod_date'), $this->get_field_name('linkify_mod_date'), checked($linkify_mod_date, true, false)); ?> </div> <div class="pis-column"> <?php // ================= Utility separator pis_form_input_text(__('Use this separator between author, date and comments', 'posts-in-sidebar'), $this->get_field_id('utility_sep'), $this->get_field_name('utility_sep'), esc_attr($instance['utility_sep']), '|', __('A space will be added before and after the separator.', 'posts-in-sidebar')); ?> <?php // ================= Section position pis_form_checkbox(__('Display this section after the title of the post', 'posts-in-sidebar'), $this->get_field_id('utility_after_title'), $this->get_field_name('utility_after_title'), checked($utility_after_title, true, false)); ?> </div> </div> </div> </div> <div class="pis-section"> <h4 class="pis-widget-title"><?php _e('Taxonomies', 'posts-in-sidebar'); ?> </h4> <div class="pis-container"> <div class="pis-column-container"> <div class="pis-column"> <h4><?php _e('Categories', 'posts-in-sidebar'); ?> </h4> <?php // ================= Post categories pis_form_checkbox(__('Show the categories', 'posts-in-sidebar'), $this->get_field_id('categories'), $this->get_field_name('categories'), checked($categories, true, false)); ?> <?php // ================= Categories text pis_form_input_text(__('Use this text before categories list', 'posts-in-sidebar'), $this->get_field_id('categ_text'), $this->get_field_name('categ_text'), esc_attr($instance['categ_text']), __('Category:', 'posts-in-sidebar')); ?> <?php // ================= Categories separator pis_form_input_text(__('Use this separator between categories', 'posts-in-sidebar'), $this->get_field_id('categ_sep'), $this->get_field_name('categ_sep'), esc_attr($instance['categ_sep']), ',', __('A space will be added after the separator.', 'posts-in-sidebar')); ?> </div> <div class="pis-column"> <h4><?php _e('Tags', 'posts-in-sidebar'); ?> </h4> <?php // ================= Post tags pis_form_checkbox(__('Show the tags', 'posts-in-sidebar'), $this->get_field_id('tags'), $this->get_field_name('tags'), checked($tags, true, false)); ?> <?php // ================= Tags text pis_form_input_text(__('Use this text before tags list', 'posts-in-sidebar'), $this->get_field_id('tags_text'), $this->get_field_name('tags_text'), esc_attr($instance['tags_text']), __('Tags:', 'posts-in-sidebar')); ?> <?php // ================= Hashtag pis_form_input_text(__('Use this hashtag', 'posts-in-sidebar'), $this->get_field_id('hashtag'), $this->get_field_name('hashtag'), esc_attr($instance['hashtag']), '#'); ?> <?php // ================= Tags separator pis_form_input_text(__('Use this separator between tags', 'posts-in-sidebar'), $this->get_field_id('tag_sep'), $this->get_field_name('tag_sep'), esc_attr($instance['tag_sep']), ',', __('A space will be added after the separator.', 'posts-in-sidebar')); ?> </div> <div class="pis-column"> <h4><?php _e('Custom taxonomies', 'posts-in-sidebar'); ?> </h4> <?php // ================= Custom taxonomies pis_form_checkbox(__('Show the custom taxonomies', 'posts-in-sidebar'), $this->get_field_id('display_custom_tax'), $this->get_field_name('display_custom_tax'), checked($display_custom_tax, true, false)); ?> <?php // ================= Terms hashtag pis_form_input_text(__('Use this hashtag for terms', 'posts-in-sidebar'), $this->get_field_id('term_hashtag'), $this->get_field_name('term_hashtag'), esc_attr($instance['term_hashtag']), '#'); ?> <?php // ================= Terms separator pis_form_input_text(__('Use this separator between terms', 'posts-in-sidebar'), $this->get_field_id('term_sep'), $this->get_field_name('term_sep'), esc_attr($instance['term_sep']), ',', __('A space will be added after the separator.', 'posts-in-sidebar')); ?> </div> </div> </div> </div> <div class="pis-section pis-2col"> <h4 class="pis-widget-title"><?php _e('The custom field', 'posts-in-sidebar'); ?> </h4> <div class="pis-container"> <div class="pis-column-container"> <div class="pis-column"> <?php // ================= Display custom field pis_form_checkbox(__('Display the custom field of the post', 'posts-in-sidebar'), $this->get_field_id('custom_field'), $this->get_field_name('custom_field'), checked($custom_field, true, false)); ?> <?php // ================= Custom fields text pis_form_input_text(__('Use this text before the custom field', 'posts-in-sidebar'), $this->get_field_id('custom_field_txt'), $this->get_field_name('custom_field_txt'), esc_attr($instance['custom_field_txt']), __('Custom field:', 'posts-in-sidebar')); ?> <?php // ================= Which custom field $options = array(); $metas = (array) pis_meta(); foreach ($metas as $meta) { if (!is_protected_meta($meta, 'post')) { $options[] = array('value' => $meta, 'desc' => $meta); } } pis_form_select(__('Display this custom field', 'posts-in-sidebar'), $this->get_field_id('meta'), $this->get_field_name('meta'), $options, $instance['meta']); ?> </div> <div class="pis-column"> <?php // ================= Custom field key pis_form_checkbox(__('Also display the key of the custom field', 'posts-in-sidebar'), $this->get_field_id('custom_field_key'), $this->get_field_name('custom_field_key'), checked($custom_field_key, true, false)); ?> <?php // ================= Custom field separator pis_form_input_text(__('Use this separator between meta key and value', 'posts-in-sidebar'), $this->get_field_id('custom_field_sep'), $this->get_field_name('custom_field_sep'), esc_attr($instance['custom_field_sep']), ':'); ?> </div> </div> </div> </div> <div class="pis-section pis-2col"> <h4 class="pis-widget-title"><?php _e('The link to the archive', 'posts-in-sidebar'); ?> </h4> <div class="pis-container"> <div class="pis-column-container"> <div class="pis-column"> <?php // ================= Taxonomy archive link pis_form_checkbox(__('Display the link to the taxonomy archive', 'posts-in-sidebar'), $this->get_field_id('archive_link'), $this->get_field_name('archive_link'), checked($archive_link, true, false)); ?> <?php // ================= Which taxonomy $options = array('author' => array('value' => 'author', 'desc' => __('Author', 'posts-in-sidebar')), 'category' => array('value' => 'category', 'desc' => __('Category', 'posts-in-sidebar')), 'tag' => array('value' => 'tag', 'desc' => __('Tag', 'posts-in-sidebar'))); /* Custom post type */ $custom_post_types = get_post_types(array('_builtin' => false)); if ($custom_post_types) { $options[] = array('value' => 'custom_post_type', 'desc' => __('Custom post type', 'posts-in-sidebar')); } /* Custom taxonomy */ $custom_taxonomy = get_taxonomies(array('public' => true, '_builtin' => false)); if ($custom_taxonomy) { $options[] = array('value' => 'custom_taxonomy', 'desc' => __('Custom taxonomy', 'posts-in-sidebar')); } /* Post format */ if ($post_formats) { // $post_formats has been already declared (search above). foreach ($post_formats as $post_format) { $options[] = array('value' => $post_format->slug, 'desc' => sprintf(__('Post format: %s', 'posts-in-sidebar'), $post_format->name)); } } pis_form_select(__('Link to the archive of', 'posts-in-sidebar'), $this->get_field_id('link_to'), $this->get_field_name('link_to'), $options, $instance['link_to'], '', 'pis-linkto-form'); ?> </div> <div class="pis-column"> <div class="pis-linkto-tax-name"> <?php // ================= Taxonomy name for archive link pis_form_input_text(__('Taxonomy name', 'posts-in-sidebar'), $this->get_field_id('tax_name'), $this->get_field_name('tax_name'), esc_attr($instance['tax_name']), __('genre', 'posts-in-sidebar'), sprintf(__('Enter the term name of the custom taxonomy (e.g., %1$sgenre%2$s).', 'posts-in-sidebar'), '<code>', '</code>'), 'margin: 0; padding: 0.5em;'); ?> </div> <div class="pis-linkto-term-name"> <?php // ================= Taxonomy term name for archive link pis_form_input_text(__('Taxonomy term name', 'posts-in-sidebar'), $this->get_field_id('tax_term_name'), $this->get_field_name('tax_term_name'), esc_attr($instance['tax_term_name']), __('science', 'posts-in-sidebar'), sprintf(__('Enter the name of the taxonomy term (e.g., %1$sscience%2$s if the taxonomy is "genre").%3$sIf you selected "Author" in "Link to the archive of" field, enter the author slug; if you selected "Category", enter the category slug, and so on.', 'posts-in-sidebar'), '<code>', '</code>', '<br />'), 'margin: 0; padding: 0.5em;'); ?> </div> </div> </div> <?php // ================= Archive link text pis_form_input_text(__('Use this text for archive link', 'posts-in-sidebar'), $this->get_field_id('archive_text'), $this->get_field_name('archive_text'), esc_attr($instance['archive_text']), __('Display all posts by %s', 'posts-in-sidebar'), sprintf(__('Use %s to display the name of the taxonomy.', 'posts-in-sidebar'), '<code>%s</code>')); ?> </div> </div> <div class="pis-section"> <h4 class="pis-widget-title"><?php _e('When no posts are found', 'posts-in-sidebar'); ?> </h4> <div class="pis-container"> <?php // ================= When no posts are found // Text when no posts found pis_form_input_text(__('Use this text when there are no posts', 'posts-in-sidebar'), $this->get_field_id('nopost_text'), $this->get_field_name('nopost_text'), esc_attr($instance['nopost_text']), __('No posts yet.', 'posts-in-sidebar')); ?> <?php // Hide the widget if no posts found pis_form_checkbox(__('Completely hide the widget if no posts are found', 'posts-in-sidebar'), $this->get_field_id('hide_widget'), $this->get_field_name('hide_widget'), checked($hide_widget, true, false)); ?> </div> </div> </div> </div> <!-- Styles --> <div class="pis-section"> <h4 class="pis-widget-title"><?php _e('Styles', 'posts-in-sidebar'); ?> </h4> <div class="pis-container"> <p><em><?php _e('This section defines the margin for each line of the widget. Leave blank if you don\'t want to add any local style.', 'posts-in-sidebar'); ?> </em></p> <div class="pis-column-container"> <div class="pis-column"> <?php // ================= Margin unit $options = array('px' => array('value' => 'px', 'desc' => 'px'), '%' => array('value' => '%', 'desc' => '%'), 'em' => array('value' => 'em', 'desc' => 'em'), 'rem' => array('value' => 'rem', 'desc' => 'rem')); pis_form_select(__('Unit for margins', 'posts-in-sidebar'), $this->get_field_id('margin_unit'), $this->get_field_name('margin_unit'), $options, $instance['margin_unit']); ?> <p><?php printf(__('Enter here only the value without any unit, e.g. enter %1$s if you want a space of 10px or enter %2$s if you don\'t want any space.', 'posts-in-sidebar'), '<code>10</code>', '<code>0</code>'); ?> </p> </div> </div> <div class="pis-column-container"> <?php // ================= Margins ?> <div class="pis-column"> <?php pis_form_input_text(__('Introduction bottom margin', 'posts-in-sidebar'), $this->get_field_id('intro_margin'), $this->get_field_name('intro_margin'), esc_attr($instance['intro_margin'])); ?> <?php pis_form_input_text(__('Title bottom margin', 'posts-in-sidebar'), $this->get_field_id('title_margin'), $this->get_field_name('title_margin'), esc_attr($instance['title_margin'])); ?> <?php pis_form_input_text(__('Image left & right margin', 'posts-in-sidebar'), $this->get_field_id('side_image_margin'), $this->get_field_name('side_image_margin'), esc_attr($instance['side_image_margin'])); ?> <?php pis_form_input_text(__('Image bottom margin', 'posts-in-sidebar'), $this->get_field_id('bottom_image_margin'), $this->get_field_name('bottom_image_margin'), esc_attr($instance['bottom_image_margin'])); ?> </div> <div class="pis-column"> <?php pis_form_input_text(__('Excerpt bottom margin', 'posts-in-sidebar'), $this->get_field_id('excerpt_margin'), $this->get_field_name('excerpt_margin'), esc_attr($instance['excerpt_margin'])); ?> <?php pis_form_input_text(__('Utility bottom margin', 'posts-in-sidebar'), $this->get_field_id('utility_margin'), $this->get_field_name('utility_margin'), esc_attr($instance['utility_margin'])); ?> <?php pis_form_input_text(__('Categories bottom margin', 'posts-in-sidebar'), $this->get_field_id('categories_margin'), $this->get_field_name('categories_margin'), esc_attr($instance['categories_margin'])); ?> <?php pis_form_input_text(__('Tags bottom margin', 'posts-in-sidebar'), $this->get_field_id('tags_margin'), $this->get_field_name('tags_margin'), esc_attr($instance['tags_margin'])); ?> </div> <div class="pis-column"> <?php pis_form_input_text(__('Terms bottom margin', 'posts-in-sidebar'), $this->get_field_id('terms_margin'), $this->get_field_name('terms_margin'), esc_attr($instance['terms_margin'])); ?> <?php pis_form_input_text(__('Custom field bottom margin', 'posts-in-sidebar'), $this->get_field_id('custom_field_margin'), $this->get_field_name('custom_field_margin'), esc_attr($instance['custom_field_margin'])); ?> <?php pis_form_input_text(__('Archive bottom margin', 'posts-in-sidebar'), $this->get_field_id('archive_margin'), $this->get_field_name('archive_margin'), esc_attr($instance['archive_margin'])); ?> <?php pis_form_input_text(__('No-posts bottom margin', 'posts-in-sidebar'), $this->get_field_id('noposts_margin'), $this->get_field_name('noposts_margin'), esc_attr($instance['noposts_margin'])); ?> </div> </div> <!-- Custom styles --> <div class="pis-section"> <h4 class="pis-widget-title"><?php _e('Custom styles', 'posts-in-sidebar'); ?> </h4> <div class="pis-container"> <p><em> <?php printf(__('In this field you can add your own styles, for example: %s', 'posts-in-sidebar'), '<code>.pis-excerpt { color: green; }</code>'); ?> <br> <?php printf(__('To apply a style only to elements of this widget, prefix every style with this ID selector: %s', 'posts-in-sidebar'), '<code>#' . $this->id . '</code>'); ?> <br> <?php printf(__('For example: %s', 'posts-in-sidebar'), '<pre><code>#' . $this->id . ' .pis-title { font-size: 18px !important; }</code></pre>'); ?> </em></p> <?php // ================= Custom styles pis_form_textarea(__('Custom styles', 'posts-in-sidebar'), $this->get_field_id('custom_styles'), $this->get_field_name('custom_styles'), $instance['custom_styles'], __('Enter here your CSS styles', 'posts-in-sidebar'), $style = 'resize: vertical; width: 100%; height: 80px;'); ?> </div> </div> <!-- Extras --> <div class="pis-section"> <h4 class="pis-widget-title"><?php _e('Extras', 'posts-in-sidebar'); ?> </h4> <div class="pis-container"> <?php // ================= Container Class pis_form_input_text(__('Add a global container with this CSS class', 'posts-in-sidebar'), $this->get_field_id('container_class'), $this->get_field_name('container_class'), esc_attr($instance['container_class']), 'posts-container', sprintf(__('Enter the name of your container (for example, %1$s). The plugin will add a new %2$s container with this class. You can enter only one class and the name may contain only letters, hyphens and underscores. The new container will enclose all the widget, from the title to the last line.', 'posts-in-sidebar'), '<code>my-container</code>', '<code>div</code>')); ?> <?php // ================= Type of HTML for list of posts $options = array('ul' => array('value' => 'ul', 'desc' => __('Unordered list', 'posts-in-sidebar')), 'ol' => array('value' => 'ol', 'desc' => __('Ordered list', 'posts-in-sidebar'))); pis_form_select(__('Use this type of list for the posts', 'posts-in-sidebar'), $this->get_field_id('list_element'), $this->get_field_name('list_element'), $options, $instance['list_element']); ?> <?php // ================= Remove bullets and left space pis_form_checkbox(__('Try to remove the bullets and the extra left space from the list elements', 'posts-in-sidebar'), $this->get_field_id('remove_bullets'), $this->get_field_name('remove_bullets'), checked($remove_bullets, true, false), sprintf(__('If the plugin doesn\'t remove the bullets and/or the extra left space, you have to %1$sedit your CSS file%2$s manually.', 'posts-in-sidebar'), '<a href="' . admin_url('theme-editor.php') . '" target="_blank">', '</a>')); ?> </div> </div> </div> </div> <!-- Cache --> <div class="pis-section"> <h4 class="pis-widget-title"><?php _e('Cache', 'posts-in-sidebar'); ?> </h4> <div class="pis-container pis-2col"> <div class="pis-column-container"> <div class="pis-column"> <?php // ================= Cache for the query pis_form_checkbox(__('Use a cache to serve the output', 'posts-in-sidebar'), $this->get_field_id('cached'), $this->get_field_name('cached'), checked($cached, true, false), __('This option, if activated, will increase the performance but will show the same output during the defined cache time.', 'posts-in-sidebar')); ?> </div> <div class="pis-column"> <?php // ================= Cache duration pis_form_input_text(__('The cache will be used for (in seconds)', 'posts-in-sidebar'), $this->get_field_id('cache_time'), $this->get_field_name('cache_time'), esc_attr($instance['cache_time']), '3600', sprintf(__('For example, %1$s for one hour of cache. To reset the cache, enter %2$s and save the widget.', 'posts-in-sidebar'), '<code>3600</code>', '<code>0</code>')); ?> </div> </div> </div> </div> <!-- Debugging --> <div class="pis-section"> <h4 class="pis-widget-title"><?php _e('Debugging', 'posts-in-sidebar'); ?> </h4> <div class="pis-container"> <p><?php printf(__('You are using Posts in Sidebar version %s.', 'posts-in-sidebar'), '<strong>' . PIS_VERSION . '</strong>'); ?> </p> <p class="pis-alert"><strong><?php _e('Use this options for debugging purposes only. Please note that the informations will be displayed publicly on your site.', 'posts-in-sidebar'); ?> </strong></p> <?php // ================= Debug: display the query for the widget pis_form_checkbox(__('Display the query for the widget', 'posts-in-sidebar'), $this->get_field_id('debug_query'), $this->get_field_name('debug_query'), checked($debug_query, true, false)); ?> <?php // ================= Debug: display the complete set of parameters for the widget pis_form_checkbox(__('Display the complete set of parameters for the widget', 'posts-in-sidebar'), $this->get_field_id('debug_params'), $this->get_field_name('debug_params'), checked($debug_params, true, false)); ?> <?php // ================= Debug: display the total number of queries pis_form_checkbox(__('Display the total number of queries, including WordPress, current theme and all active plugins', 'posts-in-sidebar'), $this->get_field_id('debug_query_number'), $this->get_field_name('debug_query_number'), checked($debug_query_number, true, false)); ?> </div> </div> <?php }