User photo plugin (optional). If your blogs are co-authored by multiple people then you can use Co-Authors Plus plugin (optional) to display all author profiles on the post page. Author: Debashish Chakrabarty Author URI: http://www.debashish.com Min WP Version: 3.0 */ //----------------------------------------------------------------------------- ?> 'AuthorSpotlight_Widget', 'description' => "Sidebar widget to display Author(s)' profile on a post page." ); /* Widget control settings. */ $control_ops = array('width' => 200, 'height' => 300); parent::__construct('authorspotlight', __('AuthorSpotlight'), $widget_ops, $control_ops); $this->icon_image_url = plugin_dir_url(__FILE__) . 'images/'; } function widget( $args, $instance ) { // If Co-Authors plus plugin exists display all co-aothor profiles one after another if(function_exists('coauthors_posts_links')) { $i = new CoAuthorsIterator(); $cnt = 1; while($i->iterate()){ // the iterator overwrites the global authordata variable on each iteration $instance['seq'] = $cnt++; $instance['isLast'] = $i->is_last(); $this->_displayAuthor($args, $instance); } } else { // Normal behavior, one author per blog post $instance['seq'] = 1; $instance['isLast'] = true; $this->_displayAuthor( $args, $instance); } } function form($instance) { $instance = wp_parse_args( (array) $instance, array( 'title' => 'Author Spotlight', 'readfulltext' => 'Read Full', 'moretext' => 'More posts by the Author »', 'websitetext' => 'Website: ', 'charlimit' => '1000') ); $title = strip_tags($instance['title']); $readfulltext = strip_tags($instance['readfulltext']); $moretext = strip_tags($instance['moretext']); $websitetext = strip_tags($instance['websitetext']); $charlimit = strip_tags($instance['charlimit']); ?>
Which social icons should be displayed for the author?
_getIconsAsArray() as $key => $data ) {
printf('get_field_id($key), $this->get_field_name($key));
printf("%s", checked( 1, $instance[$key] ));
echo(' /> ');
printf('', $data['img_src'], $data['img_title'] );
printf('%s', $data['img_seperator']);
}
?>
Note: To display custom photos with User Profiles, please use the User photo plugin. The CoAuthors Plus plugin will help you add multiple authors and display their profiles.
_getIconsAsArray() as $key => $data ) { $instance[$key] = strip_tags($new_instance[$key]); } return $instance; } // Does the actual work of preparing the profile markup private function _displayAuthor($args, $instance){ global $authordata; extract( $args ); // extract arguments if((is_single() || is_page()) && $authordata->ID){ if($instance['seq'] == 1){ echo $before_widget; echo $before_title . $instance['title'] . $after_title; } echo '"; if($instance['isLast']){ echo $after_widget; } } } // Returns a trimmed String of specified length function _getSnippet($text, $length=1000, $tail="...") { $text = trim($text); $txtl = strlen($text); if($txtl > $length) { for($i=1;$text[$length-$i]!=" ";$i++) { if($i == $length) { return substr($text,0,$length) . $tail; } } $text = substr($text,0,$length-$i+1) . $tail; } return $text; } function _getIconsAsArray() { return array( 'home' => array( 'img_src' => $this->icon_image_url . 'home.png', 'img_title' => 'Homepage', 'img_seperator' => ' ' ), 'facebook' => array( 'img_src' => $this->icon_image_url . 'facebook.png', 'img_title' => 'Facebook', 'img_seperator' => ' ' ), 'twitter' => array( 'img_src' => $this->icon_image_url . 'twitter.png', 'img_title' => 'Twitter', 'img_seperator' => ' ' ), 'linkedin' => array( 'img_src' => $this->icon_image_url . 'linkedin.png', 'img_title' => 'LinkedIn', 'img_seperator' => ' ' ), 'flickr' => array( 'img_src' => $this->icon_image_url . 'flickr.png', 'img_title' => 'Flickr', 'img_seperator' => ' ' ), 'myspace' => array( 'img_src' => $this->icon_image_url . 'myspace.png', 'img_title' => 'MySpace', 'img_seperator' => '