2004-01-27 04:58:01 -05:00
< ? php
2004-04-18 15:20:37 -04:00
function the_author ( $idmode = '' , $echo = true ) {
global $authordata ;
if ( empty ( $idmode )) {
$idmode = $authordata -> user_idmode ;
}
2004-04-26 23:59:13 -04:00
2004-04-18 15:20:37 -04: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 04:58:01 -05: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-17 19:48:42 -04:00
global $id , $post ; $posts = get_usernumposts ( $post -> post_author ); echo $posts ;
2004-01-27 04:58:01 -05:00
}
2004-04-18 15:20:37 -04:00
function the_author_posts_link ( $idmode = '' ) {
global $id , $authordata ;
echo '<a href="' . get_author_link ( 0 , $authordata -> ID , $authordata -> user_nicename ) . '" title="' . sprintf ( __ ( " Posts by %s " ), htmlspecialchars ( the_author ( $idmode , false ))) . '">' . stripslashes ( the_author ( $idmode , false )) . '</a>' ;
}
2004-03-19 11:20:49 -05:00
function get_author_link ( $echo = false , $author_id , $author_nicename ) {
2004-04-26 23:59:13 -04:00
global $wpdb , $tableusers , $post , $querystring_start , $querystring_equal , $cache_userdata ;
2004-03-19 11:20:49 -05:00
$auth_ID = $author_id ;
$permalink_structure = get_settings ( 'permalink_structure' );
if ( '' == $permalink_structure ) {
2004-04-28 03:27:03 -04:00
$file = get_settings ( 'home' ) . '/' . get_settings ( 'blogfilename' );
2004-03-19 11:20:49 -05:00
$link = $file . $querystring_start . 'author' . $querystring_equal . $auth_ID ;
} else {
2004-04-26 23:59:13 -04:00
if ( '' == $author_nicename ) $author_nicename = $cache_userdata [ $author_id ] -> author_nicename ;
2004-03-19 11:20:49 -05:00
// Get any static stuff from the front
$front = substr ( $permalink_structure , 0 , strpos ( $permalink_structure , '%' ));
2004-04-28 03:27:03 -04:00
$link = get_settings ( 'home' ) . $front . 'author/' ;
2004-03-19 11:20:49 -05: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-22 23:45:27 -05:00
if ( ! isset ( $r [ 'feed' ])) $r [ 'feed' ] = '' ;
if ( ! isset ( $r [ 'feed_image' ])) $r [ 'feed_image' ] = '' ;
2004-03-19 11:20:49 -05:00
2004-03-22 23:45:27 -05:00
list_authors ( $r [ 'optioncount' ], $r [ 'exclude_admin' ], $r [ 'show_fullname' ], $r [ hide_empty ], $r [ 'feed' ], $r [ 'feed_image' ]);
2004-03-19 11:20:49 -05:00
}
2004-03-22 23:45:27 -05:00
function list_authors ( $optioncount = false , $exclude_admin = true , $show_fullname = false , $hide_empty = true , $feed = '' , $feed_image = '' ) {
2004-03-19 11:20:49 -05:00
global $tableusers , $wpdb , $blogfilename ;
$query = " SELECT ID, user_nickname, user_firstname, user_lastname, user_nicename from $tableusers " . ( $exclude_admin ? " WHERE user_nickname <> 'admin' " : '' ) . " ORDER BY user_nickname " ;
$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-04-17 11:56:23 -04:00
$link = '<a href="' . get_author_link ( 0 , $author -> ID , $author -> user_nicename ) . '" title="' . sprintf ( __ ( " Posts by %s " ), htmlspecialchars ( $author -> user_nickname )) . '">' . stripslashes ( $name ) . '</a>' ;
2004-03-22 23:45:27 -05: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 )) {
$title = ' title="' . stripslashes ( $feed ) . '"' ;
$alt = ' alt="' . stripslashes ( $feed ) . '"' ;
$name = stripslashes ( $feed );
$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 11:20:49 -05:00
}
2004-03-22 23:45:27 -05:00
if ( ! ( $posts == 0 && $hide_empty )) echo " $link </li> " ;
2004-03-19 11:20:49 -05:00
}
}
2004-01-27 04:58:01 -05:00
?>