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: 2.7 */ //----------------------------------------------------------------------------- ?> iterate()){ // the iterator overwrites the global authordata variable on each iteration displayAuthor($args); } } else { // Normal behavior, one author per blog post displayAuthor($authordata, $args); } // Output done return; } // Does the actual work of preparing the profile markup function displayAuthor($args){ global $authordata; extract( $args ); // extract arguments // Would not work on any other page than the "Single" if(is_single()){ $author_posts_link = get_author_posts_url($authordata->ID, $authordata->user_nicename ); $options = get_option('authorprofile_widget'); // get options echo $before_widget; echo $before_title . $options['title'] . $after_title; //Display author name echo '

'.get_the_author_firstname().' '.get_the_author_lastname().'

'; //Display author URL, if present if($authordata->user_url && !('http://' == $authordata->user_url)) : echo ''. $options['websitetext'] . ' '.get_the_author_url().'
'; endif; //Display User photo OR the Gravatar if(function_exists('userphoto_exists') && userphoto_exists($authordata)){ userphoto_thumbnail($authordata); } else { echo get_avatar($authordata->ID, 96); } //Display author profile, with link to full profile echo '
'.getSnippet(get_the_author_description(),$options['charlimit'],'...').''.$options['readfulltext'].'
'; echo ''; echo $after_widget; } } function authorprofile_widget_control() { $options = $newoptions = get_option('authorprofile_widget'); // get options // set new options if( $_POST['authorprofile-widget-submit'] ) { $newoptions['title'] = strip_tags( stripslashes($_POST['authorprofile-widget-title']) ); $newoptions['readfulltext'] = strip_tags( stripslashes($_POST['authorprofile-readfull-text']) ); $newoptions['moretext'] = strip_tags( stripslashes($_POST['authorprofile-moreposts-text']) ); $newoptions['websitetext'] = strip_tags( stripslashes($_POST['authorprofile-website-text']) ); $newoptions['charlimit'] = strip_tags( stripslashes($_POST['authorprofile-char-limit']) ); } // update options if needed if( $options != $newoptions ) { $options = $newoptions; update_option('authorprofile_widget', $options); } // output echo '

'._e('Title'); echo ''; echo '

'; echo '

'._e('"Website" text'); echo ''; echo '

'; echo '

'._e('"More articles by author" text'); echo ''; echo '

'; echo '

'._e('Author profile character limit'); echo ''; echo '

'; echo '

'._e('"Read full profile" text'); echo ''; echo '

'; echo '

Note: To display custom photos with User Profiles, please install/activate the User photo plugin and upload the photo from profile page.

'; echo ''; } // activate and deactivate plugin function authorprofile_activate() { // options, default values $options = array( 'widget' => array( 'title' => 'Author Spotlight', 'moretext' => 'More posts by the Author »', 'readfulltext' => 'Read Full', 'websitetext' => 'Website: ', 'charlimit' => 1000 ) ); // register option add_option( 'authorprofile_widget', $options['widget'] ); // activated return; } function authorprofile_deactivate() { // unregister option delete_option('authorprofile_widget'); // deactivated return; } // initialization function authorprofile_init() { // register widget $class['classname'] = 'authorprofile_widget'; wp_register_sidebar_widget('post_author_profile', __('Author Spotlight'), 'authorprofile_widget', $class); wp_register_widget_control('post_author_profile', __('Author Spotlight'), 'authorprofile_widget_control', 'width=200&height=200'); // initialization done return; } // 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; } // actions add_action( 'activate_'.plugin_basename(__FILE__), 'authorprofile_activate' ); add_action( 'deactivate_'.plugin_basename(__FILE__), 'authorprofile_deactivate' ); add_action( 'init', 'authorprofile_init'); ?>