function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     echo $before_widget;
     // Add a new container if the "Container Class" is not empty
     if ($instance['container_class']) {
         echo '<div class="' . $instance['container_class'] . '">';
     }
     if ($title && $instance['title_link']) {
         echo $before_title . '<a class="pis-title-link" href="' . $instance['title_link'] . '">' . $title . '</a>' . $after_title;
     } else {
         if ($title) {
             echo $before_title . $title . $after_title;
         }
     }
     pis_posts_in_sidebar(array('intro' => $instance['intro'], 'post_type' => $instance['post_type'], 'posts_id' => $instance['posts_id'], 'author' => $instance['author'], 'cat' => $instance['cat'], 'tag' => $instance['tag'], 'post_format' => $instance['post_format'], 'number' => $instance['number'], 'orderby' => $instance['orderby'], 'order' => $instance['order'], 'exclude_current_post' => $instance['exclude_current_post'], 'post_not_in' => $instance['post_not_in'], 'cat_not_in' => $instance['cat_not_in'], 'tag_not_in' => $instance['tag_not_in'], 'offset_number' => $instance['offset_number'], 'post_status' => $instance['post_status'], 'post_meta_key' => $instance['post_meta_key'], 'post_meta_val' => $instance['post_meta_val'], 'ignore_sticky' => $instance['ignore_sticky'], 'display_title' => $instance['display_title'], 'link_on_title' => $instance['link_on_title'], 'display_image' => $instance['display_image'], 'image_size' => $instance['image_size'], 'image_align' => $instance['image_align'], 'image_before_title' => $instance['image_before_title'], 'excerpt' => $instance['excerpt'], 'arrow' => $instance['arrow'], 'exc_length' => $instance['exc_length'], 'the_more' => $instance['the_more'], 'exc_arrow' => $instance['exc_arrow'], 'utility_after_title' => $instance['utility_after_title'], 'display_author' => $instance['display_author'], 'author_text' => $instance['author_text'], 'linkify_author' => $instance['linkify_author'], 'display_date' => $instance['display_date'], 'date_text' => $instance['date_text'], 'linkify_date' => $instance['linkify_date'], 'comments' => $instance['comments'], 'comments_text' => $instance['comments_text'], 'utility_sep' => $instance['utility_sep'], 'categories' => $instance['categories'], 'categ_text' => $instance['categ_text'], 'categ_sep' => $instance['categ_sep'], 'tags' => $instance['tags'], 'tags_text' => $instance['tags_text'], 'hashtag' => $instance['hashtag'], 'tag_sep' => $instance['tag_sep'], 'custom_field' => $instance['custom_field'], 'custom_field_txt' => $instance['custom_field_txt'], 'meta' => $instance['meta'], 'custom_field_key' => $instance['custom_field_key'], 'custom_field_sep' => $instance['custom_field_sep'], 'archive_link' => $instance['archive_link'], 'link_to' => $instance['link_to'], 'archive_text' => $instance['archive_text'], 'nopost_text' => $instance['nopost_text'], 'list_element' => $instance['list_element'], 'remove_bullets' => $instance['remove_bullets'], 'margin_unit' => $instance['margin_unit'], 'intro_margin' => $instance['intro_margin'], 'title_margin' => $instance['title_margin'], 'side_image_margin' => $instance['side_image_margin'], 'bottom_image_margin' => $instance['bottom_image_margin'], 'excerpt_margin' => $instance['excerpt_margin'], 'utility_margin' => $instance['utility_margin'], 'categories_margin' => $instance['categories_margin'], 'tags_margin' => $instance['tags_margin'], 'custom_field_margin' => $instance['custom_field_margin'], 'archive_margin' => $instance['archive_margin'], 'noposts_margin' => $instance['noposts_margin'], 'custom_styles' => $instance['custom_styles'], 'cached' => $instance['cached'], 'cache_time' => $instance['cache_time'], 'widget_id' => $this->id));
     if ($instance['container_class']) {
         echo '</div>';
     }
     echo $after_widget;
 }
示例#2
0
 /**
  * Display the content of the widget in the front-end.
  *
  * @param array $args
  * @param array $instance
  * @since 1.0
  */
 public function widget($args, $instance)
 {
     /**
      * Extract $args array keys into single variables.
      * Some of these are:
      * 		$args['before_widget']
      * 		$args['after_widget']
      * 		$args['before_title']
      * 		$args['after_title']
      *
      * @since 1.0
      */
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     /**
      * Change the widget title if the user wants a different title in single posts.
      * @since 3.2
      */
     if (isset($instance['get_from_same_cat']) && $instance['get_from_same_cat'] && isset($instance['title_same_cat']) && !empty($instance['title_same_cat']) && is_singular('post')) {
         $title = $instance['title_same_cat'];
         $the_category = get_the_category(get_the_ID());
         $the_category_name = $the_category[0]->name;
         $title = str_replace('%s', $the_category_name, $title);
     }
     echo '<!-- Start Posts in Sidebar - ' . $widget_id . ' -->';
     echo $before_widget;
     // Add a new container if the "Container Class" is not empty
     if (isset($instance['container_class']) && !empty($instance['container_class'])) {
         echo '<div class="' . $instance['container_class'] . '">';
     }
     if ($title && isset($instance['title_link']) && !empty($instance['title_link'])) {
         echo $before_title . '<a class="pis-title-link" href="' . esc_url($instance['title_link']) . '">' . $title . '</a>' . $after_title;
     } else {
         if ($title) {
             echo $before_title . $title . $after_title;
         }
     }
     /*
      * Check for non-existent values in the database.
      * This avoids PHP notices.
      */
     if (!isset($instance['intro'])) {
         $instance['intro'] = '';
     }
     if (!isset($instance['post_type'])) {
         $instance['post_type'] = 'post';
     }
     if (!isset($instance['posts_id'])) {
         $instance['posts_id'] = '';
     }
     if (!isset($instance['author_in'])) {
         $instance['author_in'] = '';
     }
     if (!isset($instance['post_parent_in'])) {
         $instance['post_parent_in'] = '';
     }
     if (!isset($instance['post_format'])) {
         $instance['post_format'] = '';
     }
     if (!isset($instance['search'])) {
         $instance['search'] = NULL;
     }
     if (!isset($instance['get_from_same_cat'])) {
         $instance['get_from_same_cat'] = false;
     }
     if (!isset($instance['title_same_cat'])) {
         $instance['title_same_cat'] = '';
     }
     if (!isset($instance['relation'])) {
         $instance['relation'] = '';
     }
     if (!isset($instance['taxonomy_aa'])) {
         $instance['taxonomy_aa'] = '';
     }
     if (!isset($instance['field_aa'])) {
         $instance['field_aa'] = 'slug';
     }
     if (!isset($instance['terms_aa'])) {
         $instance['terms_aa'] = '';
     }
     if (!isset($instance['operator_aa'])) {
         $instance['operator_aa'] = 'IN';
     }
     if (!isset($instance['relation_a'])) {
         $instance['relation_a'] = '';
     }
     if (!isset($instance['taxonomy_ab'])) {
         $instance['taxonomy_ab'] = '';
     }
     if (!isset($instance['field_ab'])) {
         $instance['field_ab'] = 'slug';
     }
     if (!isset($instance['terms_ab'])) {
         $instance['terms_ab'] = '';
     }
     if (!isset($instance['operator_ab'])) {
         $instance['operator_ab'] = 'IN';
     }
     if (!isset($instance['taxonomy_ba'])) {
         $instance['taxonomy_ba'] = '';
     }
     if (!isset($instance['field_ba'])) {
         $instance['field_ba'] = 'slug';
     }
     if (!isset($instance['terms_ba'])) {
         $instance['terms_ba'] = '';
     }
     if (!isset($instance['operator_ba'])) {
         $instance['operator_ba'] = 'IN';
     }
     if (!isset($instance['relation_b'])) {
         $instance['relation_b'] = '';
     }
     if (!isset($instance['taxonomy_bb'])) {
         $instance['taxonomy_bb'] = '';
     }
     if (!isset($instance['field_bb'])) {
         $instance['field_bb'] = 'slug';
     }
     if (!isset($instance['terms_bb'])) {
         $instance['terms_bb'] = '';
     }
     if (!isset($instance['operator_bb'])) {
         $instance['operator_bb'] = 'IN';
     }
     if (!isset($instance['date_year'])) {
         $instance['date_year'] = '';
     }
     if (!isset($instance['date_month'])) {
         $instance['date_month'] = '';
     }
     if (!isset($instance['date_week'])) {
         $instance['date_week'] = '';
     }
     if (!isset($instance['date_day'])) {
         $instance['date_day'] = '';
     }
     if (!isset($instance['date_hour'])) {
         $instance['date_hour'] = '';
     }
     if (!isset($instance['date_minute'])) {
         $instance['date_minute'] = '';
     }
     if (!isset($instance['date_second'])) {
         $instance['date_second'] = '';
     }
     if (!isset($instance['date_after_year'])) {
         $instance['date_after_year'] = '';
     }
     if (!isset($instance['date_after_month'])) {
         $instance['date_after_month'] = '';
     }
     if (!isset($instance['date_after_day'])) {
         $instance['date_after_day'] = '';
     }
     if (!isset($instance['date_before_year'])) {
         $instance['date_before_year'] = '';
     }
     if (!isset($instance['date_before_month'])) {
         $instance['date_before_month'] = '';
     }
     if (!isset($instance['date_before_day'])) {
         $instance['date_before_day'] = '';
     }
     if (!isset($instance['date_inclusive'])) {
         $instance['date_inclusive'] = false;
     }
     if (!isset($instance['date_column'])) {
         $instance['date_column'] = '';
     }
     if (!isset($instance['author_not_in'])) {
         $instance['author_not_in'] = '';
     }
     if (!isset($instance['exclude_current_post'])) {
         $instance['exclude_current_post'] = false;
     }
     if (!isset($instance['post_not_in'])) {
         $instance['post_not_in'] = '';
     }
     if (!isset($instance['cat_not_in'])) {
         $instance['cat_not_in'] = '';
     }
     if (!isset($instance['tag_not_in'])) {
         $instance['tag_not_in'] = '';
     }
     if (!isset($instance['post_parent_not_in'])) {
         $instance['post_parent_not_in'] = '';
     }
     if (!isset($instance['title_tooltip'])) {
         $instance['title_tooltip'] = __('Permalink to', 'posts-in-sidebar');
     }
     if (!isset($instance['image_align'])) {
         $instance['image_align'] = 'no_change';
     }
     if (!isset($instance['image_before_title'])) {
         $instance['image_before_title'] = false;
     }
     if (!isset($instance['image_link'])) {
         $instance['image_link'] = '';
     }
     if (!isset($instance['custom_image_url'])) {
         $instance['custom_image_url'] = '';
     }
     if (!isset($instance['custom_img_no_thumb'])) {
         $instance['custom_img_no_thumb'] = true;
     }
     if (!isset($instance['the_more'])) {
         $instance['the_more'] = __('Read more&hellip;', 'posts-in-sidebar');
     }
     if (!isset($instance['display_author'])) {
         $instance['display_author'] = false;
     }
     if (!isset($instance['author_text'])) {
         $instance['author_text'] = __('By', 'posts-in-sidebar');
     }
     if (!isset($instance['linkify_author'])) {
         $instance['linkify_author'] = false;
     }
     if (!isset($instance['gravatar_display'])) {
         $instance['gravatar_display'] = false;
     }
     if (!isset($instance['gravatar_size'])) {
         $instance['gravatar_size'] = 32;
     }
     if (!isset($instance['gravatar_default'])) {
         $instance['gravatar_default'] = '';
     }
     if (!isset($instance['gravatar_position'])) {
         $instance['gravatar_position'] = 'next_author';
     }
     if (!isset($instance['date_text'])) {
         $instance['date_text'] = __('Published on', 'posts-in-sidebar');
     }
     if (!isset($instance['linkify_date'])) {
         $instance['linkify_date'] = false;
     }
     if (!isset($instance['display_mod_date'])) {
         $instance['display_mod_date'] = false;
     }
     if (!isset($instance['mod_date_text'])) {
         $instance['mod_date_text'] = __('Modified on', 'posts-in-sidebar');
     }
     if (!isset($instance['linkify_mod_date'])) {
         $instance['linkify_mod_date'] = false;
     }
     if (!isset($instance['comments_text'])) {
         $instance['comments_text'] = __('Comments:', 'posts-in-sidebar');
     }
     if (!isset($instance['linkify_comments'])) {
         $instance['linkify_comments'] = true;
     }
     if (!isset($instance['utility_sep'])) {
         $instance['utility_sep'] = '|';
     }
     if (!isset($instance['utility_after_title'])) {
         $instance['utility_after_title'] = false;
     }
     if (!isset($instance['categories'])) {
         $instance['categories'] = false;
     }
     if (!isset($instance['categ_text'])) {
         $instance['categ_text'] = __('Category:', 'posts-in-sidebar');
     }
     if (!isset($instance['categ_sep'])) {
         $instance['categ_sep'] = ',';
     }
     if (!isset($instance['tags'])) {
         $instance['tags'] = false;
     }
     if (!isset($instance['tags_text'])) {
         $instance['tags_text'] = __('Tags:', 'posts-in-sidebar');
     }
     if (!isset($instance['hashtag'])) {
         $instance['hashtag'] = '#';
     }
     if (!isset($instance['tag_sep'])) {
         $instance['tag_sep'] = '';
     }
     if (!isset($instance['display_custom_tax'])) {
         $instance['display_custom_tax'] = false;
     }
     if (!isset($instance['term_hashtag'])) {
         $instance['term_hashtag'] = '';
     }
     if (!isset($instance['term_sep'])) {
         $instance['term_sep'] = ',';
     }
     if (!isset($instance['custom_field'])) {
         $instance['custom_field'] = false;
     }
     if (!isset($instance['custom_field_txt'])) {
         $instance['custom_field_txt'] = '';
     }
     if (!isset($instance['meta'])) {
         $instance['meta'] = '';
     }
     if (!isset($instance['custom_field_key'])) {
         $instance['custom_field_key'] = false;
     }
     if (!isset($instance['custom_field_sep'])) {
         $instance['custom_field_sep'] = '';
     }
     if (!isset($instance['tax_name'])) {
         $instance['tax_name'] = '';
     }
     if (!isset($instance['tax_term_name'])) {
         $instance['tax_term_name'] = '';
     }
     if (!isset($instance['nopost_text'])) {
         $instance['nopost_text'] = __('No posts yet.', 'posts-in-sidebar');
     }
     if (!isset($instance['hide_widget'])) {
         $instance['hide_widget'] = false;
     }
     if (!isset($instance['margin_unit'])) {
         $instance['margin_unit'] = 'px';
     }
     if (!isset($instance['intro_margin'])) {
         $instance['intro_margin'] = NULL;
     }
     if (!isset($instance['title_margin'])) {
         $instance['title_margin'] = NULL;
     }
     if (!isset($instance['side_image_margin'])) {
         $instance['side_image_margin'] = NULL;
     }
     if (!isset($instance['bottom_image_margin'])) {
         $instance['bottom_image_margin'] = NULL;
     }
     if (!isset($instance['excerpt_margin'])) {
         $instance['excerpt_margin'] = NULL;
     }
     if (!isset($instance['utility_margin'])) {
         $instance['utility_margin'] = NULL;
     }
     if (!isset($instance['categories_margin'])) {
         $instance['categories_margin'] = NULL;
     }
     if (!isset($instance['tags_margin'])) {
         $instance['tags_margin'] = NULL;
     }
     if (!isset($instance['terms_margin'])) {
         $instance['terms_margin'] = NULL;
     }
     if (!isset($instance['custom_field_margin'])) {
         $instance['custom_field_margin'] = NULL;
     }
     if (!isset($instance['archive_margin'])) {
         $instance['archive_margin'] = NULL;
     }
     if (!isset($instance['noposts_margin'])) {
         $instance['noposts_margin'] = NULL;
     }
     if (!isset($instance['custom_styles'])) {
         $instance['custom_styles'] = '';
     }
     if (!isset($instance['list_element'])) {
         $instance['list_element'] = 'ul';
     }
     if (!isset($instance['remove_bullets'])) {
         $instance['remove_bullets'] = false;
     }
     if (!isset($instance['cached'])) {
         $instance['cached'] = false;
     }
     if (!isset($instance['cache_time'])) {
         $instance['cache_time'] = 3600;
     }
     if (!isset($instance['debug_query'])) {
         $instance['debug_query'] = false;
     }
     if (!isset($instance['debug_params'])) {
         $instance['debug_params'] = false;
     }
     if (!isset($instance['debug_query_number'])) {
         $instance['debug_query_number'] = false;
     }
     /**
      * Execute the main function in the front-end.
      * Some parameters are passed only for the debugging list.
      */
     pis_posts_in_sidebar(array('container_class' => $instance['container_class'], 'title' => $instance['title'], 'title_link' => $instance['title_link'], 'intro' => $instance['intro'], 'post_type' => $instance['post_type'], 'posts_id' => $instance['posts_id'], 'author' => $instance['author'], 'author_in' => $instance['author_in'], 'cat' => $instance['cat'], 'tag' => $instance['tag'], 'post_parent_in' => $instance['post_parent_in'], 'post_format' => $instance['post_format'], 'number' => $instance['number'], 'orderby' => $instance['orderby'], 'order' => $instance['order'], 'offset_number' => $instance['offset_number'], 'post_status' => $instance['post_status'], 'post_meta_key' => $instance['post_meta_key'], 'post_meta_val' => $instance['post_meta_val'], 'search' => $instance['search'], 'ignore_sticky' => $instance['ignore_sticky'], 'get_from_same_cat' => $instance['get_from_same_cat'], 'title_same_cat' => $instance['title_same_cat'], 'relation' => $instance['relation'], 'taxonomy_aa' => $instance['taxonomy_aa'], 'field_aa' => $instance['field_aa'], 'terms_aa' => $instance['terms_aa'], 'operator_aa' => $instance['operator_aa'], 'relation_a' => $instance['relation_a'], 'taxonomy_ab' => $instance['taxonomy_ab'], 'field_ab' => $instance['field_ab'], 'terms_ab' => $instance['terms_ab'], 'operator_ab' => $instance['operator_ab'], 'taxonomy_ba' => $instance['taxonomy_ba'], 'field_ba' => $instance['field_ba'], 'terms_ba' => $instance['terms_ba'], 'operator_ba' => $instance['operator_ba'], 'relation_b' => $instance['relation_b'], 'taxonomy_bb' => $instance['taxonomy_bb'], 'field_bb' => $instance['field_bb'], 'terms_bb' => $instance['terms_bb'], 'operator_bb' => $instance['operator_bb'], 'date_year' => $instance['date_year'], 'date_month' => $instance['date_month'], 'date_week' => $instance['date_week'], 'date_day' => $instance['date_day'], 'date_hour' => $instance['date_hour'], 'date_minute' => $instance['date_minute'], 'date_second' => $instance['date_second'], 'date_after_year' => $instance['date_after_year'], 'date_after_month' => $instance['date_after_month'], 'date_after_day' => $instance['date_after_day'], 'date_before_year' => $instance['date_before_year'], 'date_before_month' => $instance['date_before_month'], 'date_before_day' => $instance['date_before_day'], 'date_inclusive' => $instance['date_inclusive'], 'date_column' => $instance['date_column'], 'author_not_in' => $instance['author_not_in'], 'exclude_current_post' => $instance['exclude_current_post'], 'post_not_in' => $instance['post_not_in'], 'cat_not_in' => $instance['cat_not_in'], 'tag_not_in' => $instance['tag_not_in'], 'post_parent_not_in' => $instance['post_parent_not_in'], 'display_title' => $instance['display_title'], 'link_on_title' => $instance['link_on_title'], 'title_tooltip' => $instance['title_tooltip'], 'arrow' => $instance['arrow'], 'display_image' => $instance['display_image'], 'image_size' => $instance['image_size'], 'image_align' => $instance['image_align'], 'image_before_title' => $instance['image_before_title'], 'image_link' => $instance['image_link'], 'custom_image_url' => $instance['custom_image_url'], 'custom_img_no_thumb' => $instance['custom_img_no_thumb'], 'excerpt' => $instance['excerpt'], 'exc_length' => $instance['exc_length'], 'the_more' => $instance['the_more'], 'exc_arrow' => $instance['exc_arrow'], 'display_author' => $instance['display_author'], 'author_text' => $instance['author_text'], 'linkify_author' => $instance['linkify_author'], 'gravatar_display' => $instance['gravatar_display'], 'gravatar_size' => $instance['gravatar_size'], 'gravatar_default' => $instance['gravatar_default'], 'gravatar_position' => $instance['gravatar_position'], 'display_date' => $instance['display_date'], 'date_text' => $instance['date_text'], 'linkify_date' => $instance['linkify_date'], 'display_mod_date' => $instance['display_mod_date'], 'mod_date_text' => $instance['mod_date_text'], 'linkify_mod_date' => $instance['linkify_mod_date'], 'comments' => $instance['comments'], 'comments_text' => $instance['comments_text'], 'linkify_comments' => $instance['linkify_comments'], 'utility_sep' => $instance['utility_sep'], 'utility_after_title' => $instance['utility_after_title'], 'categories' => $instance['categories'], 'categ_text' => $instance['categ_text'], 'categ_sep' => $instance['categ_sep'], 'tags' => $instance['tags'], 'tags_text' => $instance['tags_text'], 'hashtag' => $instance['hashtag'], 'tag_sep' => $instance['tag_sep'], 'display_custom_tax' => $instance['display_custom_tax'], 'term_hashtag' => $instance['term_hashtag'], 'term_sep' => $instance['term_sep'], 'custom_field' => $instance['custom_field'], 'custom_field_txt' => $instance['custom_field_txt'], 'meta' => $instance['meta'], 'custom_field_key' => $instance['custom_field_key'], 'custom_field_sep' => $instance['custom_field_sep'], 'archive_link' => $instance['archive_link'], 'link_to' => $instance['link_to'], 'tax_name' => $instance['tax_name'], 'tax_term_name' => $instance['tax_term_name'], 'archive_text' => $instance['archive_text'], 'nopost_text' => $instance['nopost_text'], 'hide_widget' => $instance['hide_widget'], 'margin_unit' => $instance['margin_unit'], 'intro_margin' => $instance['intro_margin'], 'title_margin' => $instance['title_margin'], 'side_image_margin' => $instance['side_image_margin'], 'bottom_image_margin' => $instance['bottom_image_margin'], 'excerpt_margin' => $instance['excerpt_margin'], 'utility_margin' => $instance['utility_margin'], 'categories_margin' => $instance['categories_margin'], 'tags_margin' => $instance['tags_margin'], 'terms_margin' => $instance['terms_margin'], 'custom_field_margin' => $instance['custom_field_margin'], 'archive_margin' => $instance['archive_margin'], 'noposts_margin' => $instance['noposts_margin'], 'custom_styles' => $instance['custom_styles'], 'list_element' => $instance['list_element'], 'remove_bullets' => $instance['remove_bullets'], 'cached' => $instance['cached'], 'cache_time' => $instance['cache_time'], 'widget_id' => $this->id, 'debug_query' => $instance['debug_query'], 'debug_params' => $instance['debug_params'], 'debug_query_number' => $instance['debug_query_number']));
     if (isset($instance['container_class']) && !empty($instance['container_class'])) {
         echo '</div>';
     }
     echo $after_widget;
     echo '<!-- End Posts in Sidebar - ' . $widget_id . ' -->';
 }