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_my_bns_fc_widget' ); /* Function that registers our widget. */ function load_my_bns_fc_widget() { register_widget( 'BNS_Featured_Category_Widget' ); } // Begin the mess of Excerpt Length fiascoes function get_first_words_for_bns_fc($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_Category_Widget extends WP_Widget { function BNS_Featured_Category_Widget() { /* Widget settings. */ $widget_ops = array('classname' => 'bns-featured-category', 'description' => __('Displays most recent posts from a specific featured category or categories.')); /* Widget control settings. */ $control_ops = array('width' => 450, 'height' => 350, 'id_base' => 'bns-featured-category'); /* Create the widget. */ $this->WP_Widget('bns-featured-category', 'BNS Featured Category', $widget_ops, $control_ops); } function widget( $args, $instance ) { extract( $args ); /* User-selected settings. */ $title = apply_filters('widget_title', $instance['title'] ); $cat_choice = $instance['cat_choice']; $show_count = $instance['show_count']; $show_meta = $instance['show_meta']; $show_comments = $instance['show_comments']; $show_cats = $instance['show_cats']; $show_cat_desc = $instance['show_cat_desc']; $show_tags = $instance['show_tags']; $only_titles = $instance['only_titles']; $show_full = $instance['show_full']; $excerpt_length = $instance['excerpt_length']; $count = $instance['count']; /* Plugin requires counter variable to be part of its arguments?! */ /* Before widget (defined by themes). */ echo $before_widget; /* Title of widget (before and after defined by themes). */ $cat_choice_class = ''; $cat_choice_class = preg_replace("/[,]/","-",$cat_choice); if ( $title ) echo $before_title . '' . $title . '' . $after_title; /* Display posts from widget settings. */ query_posts("cat=$cat_choice&posts_per_page=$show_count"); if ( $show_cat_desc ) { echo '
' . category_description() . '
'; } if (have_posts()) : while (have_posts()) : the_post(); /* static $count = 0; */ /* see above */ if ($count == $show_count) { break; } else { ?>
>




0) { echo get_first_words_for_bns_fc(get_the_content(), $instance['excerpt_length']); } else { the_excerpt(); } ?>
__('Featured Category'), 'cat_choice' => '1', 'count' => '0', /* resets count to zero as default */ 'show_count' => '3', 'show_meta' => false, 'show_comments' => false, 'show_cats' => false, 'show_cat_desc' => false, 'show_tags' => false, 'only_titles' => false, 'show_full' => false, 'excerpt_length' => '' ); $instance = wp_parse_args( (array) $instance, $defaults ); ?>

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

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' ); ?>" />