random authors, weighted towards authors with more posts. Configure numer of authors, title, display of post count, and author gravatar display. Version: 1.1.1 Author: Jacob M Goldman (C. Murray Consulting) Author URI: http://www.cmurrayconsulting.com Plugin: Copyright 2009 C. Murray Consulting (email : jake@cmurrayconsulting.com) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class WeightedAuthorWidget extends WP_Widget { function WeightedAuthorWidget() { $widget_ops = array('classname' => 'widget_weighted_authors', 'description' => __( "Displays authors in random order, weighted by number of posts.") ); $this->WP_Widget('weightedauthors', __('Weighted Random Authors'), $widget_ops); } function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? 'Random Authors' : $instance['title']); $limit = (is_numeric($instance['limit']) && $instance['limit'] >= 0) ? intval($instance['limit']) : 5; $expand = (!isset($instance['expand'])) ? false : $instance['expand']; echo $before_widget; echo $before_title.$title.$after_title; echo '".$after_widget; } function update($new_instance, $old_instance){ $instance = $old_instance; $instance['title'] = strip_tags(stripslashes($new_instance['title'])); $instance['limit'] = intval($new_instance['limit']); $instance['expand'] = $new_instance['expand']; $instance['show_count'] = $new_instance['show_count']; $instance['gravatar'] = $new_instance['gravatar']; return $instance; } function form($instance){ $instance = wp_parse_args((array) $instance, array('title' => 'Random Authors', 'limit' => 5, 'expand' => false, 'show_count' => false, 'gravatar' => false)); //defaults $title = htmlspecialchars($instance['title']); $limit = (is_numeric($instance['limit']) && intval($instance['limit']) >= 0) ? intval($instance['limit']) : 5; $expand_checked = ($instance['expand']) ? 'checked="checked" ' : ''; $show_count_checked = ($instance['show_count']) ? 'checked="checked" ' : ''; $gravatar_checked = ($instance['gravatar']) ? 'checked="checked" ' : ''; echo '

'; echo '

'; echo '

'; echo '

'; echo '

'; } } function WeightedAuthorInit() { register_widget('WeightedAuthorWidget'); } add_action('widgets_init', 'WeightedAuthorInit'); function WeightedAuthorHead() { if (is_active_widget(false,false,'weightedauthors')) { $path = WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)); wp_enqueue_script('weighted_random_authors_script',$path.'expand.js',array('jquery'),'1.1',true); } } add_action('wp_head','WeightedAuthorHead',0); ?>