Load_TextDomain(); // Setup the Widget data $this->WP_Widget ( False, $this->t('Author Info'), Array('description' => $this->t('You can add this widget to sidebars on author relevant sections, i.e. pages, posts or author archives.'))); $this->base_url = get_option('siteurl').'/'.Str_Replace("\\", '/', SubStr(RealPath(DirName(__FILE__)), Strlen(ABSPATH))); // Register as Widget Add_Action ('widgets_init', Array($this, 'Register')); } Function Register(){ Register_Widget(get_class($this)); Add_Action('wp_head', Array($this, 'Include_CSS')); } Function Load_TextDomain(){ $this->text_domain = get_class($this); load_textdomain ($this->text_domain, DirName(__FILE__).'/language/'.get_locale().'.mo'); } Function t ($text, $context = ''){ // Translates the string $text with context $context If ($context == '') return __($text, $this->text_domain); Else return _x($text, $context, $this->text_domain); } Function Include_CSS(){ Echo ''; } Function widget ($args, $settings){ If ($settings['only_logged_in'] && !is_user_logged_in()) return False; If ($settings['title'] == '') $settings['title'] = $this->t('About the author'); If ( $settings['author_id'] != '' ){ $obj_author = get_userdata($settings['author_id']); } ElseIf ( is_author() ){ Global $wp_query; $obj_author = $wp_query->get_queried_object(); } ElseIf ( is_singular() ) { Global $post; $obj_author = get_userdata( $post->post_author ); } Else { return False; } Echo $args['before_widget']; Echo $args['before_title'] . $settings['title'] . $args['after_title']; Echo '

'.sprintf($this->t('Author: %s'), $obj_author->display_name).'

'; // Show gravatar If ($settings['show_avatar'] && IsSet ($obj_author->user_email)) Echo get_avatar($obj_author->user_email, ($settings['avatar_size'] == '' ? 80 : IntVal($settings['avatar_size']))); // Show the profile text If (IsSet ($obj_author->description)) Echo '

'.nl2br($obj_author->description).'

'; // Show contact links $contact_p = ''; If (IsSet($settings['show_website']) && $settings['show_website'] == 'yes' && $obj_author->user_url != '') $contact_p .= 'Website'; If (IsSet($settings['show_jabber']) && $settings['show_jabber'] == 'yes' && IsSet ($obj_author->jabber)) $contact_p .= 'Jabber'; If (IsSet($settings['show_aim']) && $settings['show_aim'] == 'yes' && IsSet ($obj_author->aim)) $contact_p .= 'AIM'; If (IsSet($settings['show_yim']) && $settings['show_yim'] == 'yes' && IsSet ($obj_author->yim)) $contact_p .= 'Yahoo!'; If ($contact_p != '') Echo '

'.$contact_p.'

'; // Show link to the authors posts $posts_link_caption = SPrintF($this->t('All posts by %s'), $obj_author->display_name); Echo ''; Echo $args['after_widget']; } Function form ($settings){ // Show Form: ?>

t('Title:') ?>

/> t('Show this widget only to logged in users.')?>

t('Show the profile of this author:') ?>

/> t('Show the authors avatar') ?>

t('Avatar size (one side):') ?> px

/> t('Show the authors url link')?>

/> t('Show the authors jabber name')?>

/> t('Show the authors AIM name')?>

/> t('Show the authors YIM name')?>