2004-01-27 10:58:01 +01:00
< ? php
2004-04-18 21:20:37 +02:00
function the_author ( $idmode = '' , $echo = true ) {
global $authordata ;
if ( empty ( $idmode )) {
$idmode = $authordata -> user_idmode ;
}
2004-04-27 05:59:13 +02:00
2004-04-18 21:20:37 +02:00
if ( $idmode == 'nickname' ) $id = $authordata -> user_nickname ;
if ( $idmode == 'login' ) $id = $authordata -> user_login ;
if ( $idmode == 'firstname' ) $id = $authordata -> user_firstname ;
if ( $idmode == 'lastname' ) $id = $authordata -> user_lastname ;
if ( $idmode == 'namefl' ) $id = $authordata -> user_firstname . ' ' . $authordata -> user_lastname ;
if ( $idmode == 'namelf' ) $id = $authordata -> user_lastname . ' ' . $authordata -> user_firstname ;
if ( ! $idmode ) $id = $authordata -> user_nickname ;
if ( $echo ) echo $id ;
return $id ;
2004-01-27 10:58:01 +01:00
}
function the_author_description () {
global $authordata ;
echo $authordata -> user_description ;
}
function the_author_login () {
global $id , $authordata ; echo $authordata -> user_login ;
}
function the_author_firstname () {
global $id , $authordata ; echo $authordata -> user_firstname ;
}
function the_author_lastname () {
global $id , $authordata ; echo $authordata -> user_lastname ;
}
function the_author_nickname () {
global $id , $authordata ; echo $authordata -> user_nickname ;
}
function the_author_ID () {
global $id , $authordata ; echo $authordata -> ID ;
}
function the_author_email () {
global $id , $authordata ; echo antispambot ( $authordata -> user_email );
}
function the_author_url () {
global $id , $authordata ; echo $authordata -> user_url ;
}
function the_author_icq () {
global $id , $authordata ; echo $authordata -> user_icq ;
}
function the_author_aim () {
global $id , $authordata ; echo str_replace ( ' ' , '+' , $authordata -> user_aim );
}
function the_author_yim () {
global $id , $authordata ; echo $authordata -> user_yim ;
}
function the_author_msn () {
global $id , $authordata ; echo $authordata -> user_msn ;
}
function the_author_posts () {
2004-04-18 01:48:42 +02:00
global $id , $post ; $posts = get_usernumposts ( $post -> post_author ); echo $posts ;
2004-01-27 10:58:01 +01:00
}
2004-04-18 21:20:37 +02:00
function the_author_posts_link ( $idmode = '' ) {
global $id , $authordata ;
2004-06-18 02:22:09 +02:00
echo '<a href="' . get_author_link ( 0 , $authordata -> ID , $authordata -> user_nicename ) . '" title="' . sprintf ( __ ( " Posts by %s " ), htmlspecialchars ( the_author ( $idmode , false ))) . '">' . the_author ( $idmode , false ) . '</a>' ;
2004-04-18 21:20:37 +02:00
}
2004-03-19 17:20:49 +01:00
function get_author_link ( $echo = false , $author_id , $author_nicename ) {
2004-05-24 10:22:18 +02:00
global $wpdb , $post , $querystring_start , $querystring_equal , $cache_userdata ;
2004-03-19 17:20:49 +01:00
$auth_ID = $author_id ;
$permalink_structure = get_settings ( 'permalink_structure' );
if ( '' == $permalink_structure ) {
2004-04-28 09:27:03 +02:00
$file = get_settings ( 'home' ) . '/' . get_settings ( 'blogfilename' );
2004-03-19 17:20:49 +01:00
$link = $file . $querystring_start . 'author' . $querystring_equal . $auth_ID ;
} else {
2004-04-27 05:59:13 +02:00
if ( '' == $author_nicename ) $author_nicename = $cache_userdata [ $author_id ] -> author_nicename ;
2004-03-19 17:20:49 +01:00
// Get any static stuff from the front
$front = substr ( $permalink_structure , 0 , strpos ( $permalink_structure , '%' ));
2004-04-28 09:27:03 +02:00
$link = get_settings ( 'home' ) . $front . 'author/' ;
2004-03-19 17:20:49 +01:00
$link .= $author_nicename . '/' ;
}
if ( $echo ) echo $link ;
return $link ;
}
function get_author_rss_link ( $echo = false , $author_id , $author_nicename ) {
global $querystring_start , $querystring_equal ;
$auth_ID = $author_id ;
$permalink_structure = get_settings ( 'permalink_structure' );
if ( '' == $permalink_structure ) {
$file = get_settings ( 'siteurl' ) . '/wp-rss2.php' ;
$link = $file . $querystring_start . 'author' . $querystring_equal . $author_id ;
} else {
$link = get_author_link ( 0 , $author_id , $author_nicename );
$link = $link . " feed/ " ;
}
if ( $echo ) echo $link ;
return $link ;
}
function wp_list_authors ( $args = '' ) {
parse_str ( $args , $r );
if ( ! isset ( $r [ 'optioncount' ])) $r [ 'optioncount' ] = false ;
if ( ! isset ( $r [ 'exclude_admin' ])) $r [ 'exclude_admin' ] = true ;
if ( ! isset ( $r [ 'show_fullname' ])) $r [ 'show_fullname' ] = false ;
if ( ! isset ( $r [ 'hide_empty' ])) $r [ 'hide_empty' ] = true ;
2004-03-23 05:45:27 +01:00
if ( ! isset ( $r [ 'feed' ])) $r [ 'feed' ] = '' ;
if ( ! isset ( $r [ 'feed_image' ])) $r [ 'feed_image' ] = '' ;
2004-03-19 17:20:49 +01:00
2004-09-03 06:03:55 +02:00
list_authors ( $r [ 'optioncount' ], $r [ 'exclude_admin' ], $r [ 'show_fullname' ], $r [ 'hide_empty' ], $r [ 'feed' ], $r [ 'feed_image' ]);
2004-03-19 17:20:49 +01:00
}
2004-03-23 05:45:27 +01:00
function list_authors ( $optioncount = false , $exclude_admin = true , $show_fullname = false , $hide_empty = true , $feed = '' , $feed_image = '' ) {
2004-05-24 10:22:18 +02:00
global $wpdb , $blogfilename ;
2004-03-19 17:20:49 +01:00
2004-05-24 10:22:18 +02:00
$query = " SELECT ID, user_nickname, user_firstname, user_lastname, user_nicename from $wpdb->users " . ( $exclude_admin ? " WHERE user_nickname <> 'admin' " : '' ) . " ORDER BY user_nickname " ;
2004-03-19 17:20:49 +01:00
$authors = $wpdb -> get_results ( $query );
foreach ( $authors as $author ) {
$posts = get_usernumposts ( $author -> ID );
$name = $author -> user_nickname ;
if ( $show_fullname && ( $author -> user_firstname != '' && $author -> user_lastname != '' )) {
$name = " $author->user_firstname $author->user_lastname " ;
}
if ( ! ( $posts == 0 && $hide_empty )) echo " <li> " ;
if ( $posts == 0 ) {
if ( ! $hide_empty ) echo $name ;
} else {
2004-06-18 02:22:09 +02:00
$link = '<a href="' . get_author_link ( 0 , $author -> ID , $author -> user_nicename ) . '" title="' . sprintf ( __ ( " Posts by %s " ), htmlspecialchars ( $author -> user_nickname )) . '">' . $name . '</a>' ;
2004-03-23 05:45:27 +01:00
if ( ( ! empty ( $feed_image )) || ( ! empty ( $feed )) ) {
$link .= ' ' ;
if ( empty ( $feed_image )) {
$link .= '(' ;
}
$link .= '<a href="' . get_author_rss_link ( 0 , $author -> ID , $author -> user_nicename ) . '"' ;
if ( ! empty ( $feed )) {
2004-06-18 02:22:09 +02:00
$title = ' title="' . $feed . '"' ;
$alt = ' alt="' . $feed . '"' ;
$name = $feed ;
2004-03-23 05:45:27 +01:00
$link .= $title ;
}
$link .= '>' ;
if ( ! empty ( $feed_image )) {
$link .= " <img src= \" $feed_image\ " border = \ " 0 \" $alt $title " . ' />' ;
} else {
$link .= $name ;
}
$link .= '</a>' ;
if ( empty ( $feed_image )) {
$link .= ')' ;
}
}
if ( $optioncount ) {
$link .= ' (' . $posts . ')' ;
}
2004-03-19 17:20:49 +01:00
}
2004-03-23 05:45:27 +01:00
if ( ! ( $posts == 0 && $hide_empty )) echo " $link </li> " ;
2004-03-19 17:20:49 +01:00
}
}
2004-01-27 10:58:01 +01:00
?>