Please Update!'; if (version_compare($wp_version, "2.8", "<")) { exit ($exit_message); } /* Add our function to the widgets_init hook. */ add_action( 'widgets_init', 'load_bns_featured_tag_widget' ); /* Function that registers our widget. */ function load_bns_featured_tag_widget() { register_widget( 'BNS_Featured_Tag_Widget' ); } // Begin the mess of Excerpt Length fiascoes function get_first_words_for_bns_ft($text, $length = 55) { if (!$length) return $text; $text = strip_tags($text); $words = explode(' ', $text, $length + 1); if (count($words) > $length) { array_pop($words); array_push($words, '...'); $text = implode(' ', $words); } return $text; } // End Excerpt Length class BNS_Featured_Tag_Widget extends WP_Widget { function BNS_Featured_Tag_Widget() { /* Widget settings. */ $widget_ops = array( 'classname' => 'bns-featured-tag', 'description' => __('Displays most recent posts from a specific featured tag or tags.') ); /* Widget control settings. */ $control_ops = array( 'width' => 450, 'height' => 350, 'id_base' => 'bns-featured-tag' ); /* Create the widget. */ $this->WP_Widget( 'bns-featured-tag', 'BNS Featured Tag', $widget_ops, $control_ops ); } function widget( $args, $instance ) { extract( $args ); /* User-selected settings. */ $title = apply_filters('widget_title', $instance['title'] ); $tag_choice = $instance['tag_choice']; $show_count = $instance['show_count']; $show_meta = $instance['show_meta']; $show_comments = $instance['show_comments']; $show_cats = $instance['show_cats']; $show_tags = $instance['show_tags']; $only_titles = $instance['only_titles']; $show_full = $instance['show_full']; $excerpt_length = $instance['excerpt_length']; /* Before widget (defined by themes). */ echo $before_widget; /* Title of widget (before and after defined by themes). */ if ( $title ) echo $before_title . $title . $after_title; /* Display posts from widget settings. */ query_posts("tag=$tag_choice"); if (have_posts()) : while (have_posts()) : the_post(); static $count = 0; if ($count == $show_count) { break; } else { ?>
id="post-">




0) { echo get_first_words_for_bns_ft(get_the_content(), $instance['excerpt_length']); } else { the_excerpt(); } ?>
__('Featured Tag'), 'tag_choice' => '', 'show_count' => '3', 'show_meta' => false, 'show_comments' => false, 'show_cats' => false, 'show_tags' => false, 'only_titles' => false, 'show_full' => false, 'excerpt_length' => '' ); $instance = wp_parse_args( (array) $instance, $defaults ); ?>

id="get_field_id( 'show_meta' ); ?>" name="get_field_name( 'show_meta' ); ?>" />

id="get_field_id( 'show_comments' ); ?>" name="get_field_name( 'show_comments' ); ?>" />

id="get_field_id( 'show_cats' ); ?>" name="get_field_name( 'show_cats' ); ?>" />

id="get_field_id( 'show_tags' ); ?>" name="get_field_name( 'show_tags' ); ?>" />


The default is to show the excerpt, if it exists, or the first 55 words of the post as the excerpt.

id="get_field_id( 'only_titles' ); ?>" name="get_field_name( 'only_titles' ); ?>" />

id="get_field_id( 'show_full' ); ?>" name="get_field_name( 'show_full' ); ?>" />