| 1 |
<?php |
|---|
| 2 |
function get_the_author($idmode = '') { |
|---|
| 3 |
global $authordata; |
|---|
| 4 |
if (empty($idmode)) { |
|---|
| 5 |
$idmode = $authordata->user_idmode; |
|---|
| 6 |
} |
|---|
| 7 |
|
|---|
| 8 |
if ($idmode == 'nickname') $id = $authordata->user_nickname; |
|---|
| 9 |
if ($idmode == 'login') $id = $authordata->user_login; |
|---|
| 10 |
if ($idmode == 'firstname') $id = $authordata->user_firstname; |
|---|
| 11 |
if ($idmode == 'lastname') $id = $authordata->user_lastname; |
|---|
| 12 |
if ($idmode == 'namefl') $id = $authordata->user_firstname.' '.$authordata->user_lastname; |
|---|
| 13 |
if ($idmode == 'namelf') $id = $authordata->user_lastname.' '.$authordata->user_firstname; |
|---|
| 14 |
if (!$idmode) $id = $authordata->user_nickname; |
|---|
| 15 |
|
|---|
| 16 |
return $id; |
|---|
| 17 |
} |
|---|
| 18 |
function the_author($idmode = '', $echo = true) { |
|---|
| 19 |
if ($echo) echo get_the_author($idmode); |
|---|
| 20 |
return get_the_author($idmode); |
|---|
| 21 |
} |
|---|
| 22 |
|
|---|
| 23 |
function get_the_author_description() { |
|---|
| 24 |
global $authordata; |
|---|
| 25 |
return $authordata->user_description; |
|---|
| 26 |
} |
|---|
| 27 |
function the_author_description() { |
|---|
| 28 |
echo get_the_author_description(); |
|---|
| 29 |
} |
|---|
| 30 |
|
|---|
| 31 |
function get_the_author_login() { |
|---|
| 32 |
global $id,$authordata; return $authordata->user_login; |
|---|
| 33 |
} |
|---|
| 34 |
function the_author_login() { |
|---|
| 35 |
echo get_the_author_login(); |
|---|
| 36 |
} |
|---|
| 37 |
|
|---|
| 38 |
function get_the_author_firstname() { |
|---|
| 39 |
global $id,$authordata; return $authordata->user_firstname; |
|---|
| 40 |
} |
|---|
| 41 |
function the_author_firstname() { |
|---|
| 42 |
echo get_the_author_firstname(); |
|---|
| 43 |
} |
|---|
| 44 |
|
|---|
| 45 |
function get_the_author_lastname() { |
|---|
| 46 |
global $id,$authordata; return $authordata->user_lastname; |
|---|
| 47 |
} |
|---|
| 48 |
function the_author_lastname() { |
|---|
| 49 |
echo get_the_author_lastname(); |
|---|
| 50 |
} |
|---|
| 51 |
|
|---|
| 52 |
function get_the_author_nickname() { |
|---|
| 53 |
global $id,$authordata; return $authordata->user_nickname; |
|---|
| 54 |
} |
|---|
| 55 |
function the_author_nickname() { |
|---|
| 56 |
echo get_the_author_nickname(); |
|---|
| 57 |
} |
|---|
| 58 |
|
|---|
| 59 |
function get_the_author_ID() { |
|---|
| 60 |
global $id,$authordata; return $authordata->ID; |
|---|
| 61 |
} |
|---|
| 62 |
function the_author_ID() { |
|---|
| 63 |
echo get_the_author_id(); |
|---|
| 64 |
} |
|---|
| 65 |
|
|---|
| 66 |
function get_the_author_email() { |
|---|
| 67 |
global $authordata; |
|---|
| 68 |
return $authordata->user_email; |
|---|
| 69 |
} |
|---|
| 70 |
|
|---|
| 71 |
function the_author_email() { |
|---|
| 72 |
echo apply_filters('the_author_email', get_the_author_email() ); |
|---|
| 73 |
} |
|---|
| 74 |
|
|---|
| 75 |
function get_the_author_url() { |
|---|
| 76 |
global $id,$authordata; return $authordata->user_url; |
|---|
| 77 |
} |
|---|
| 78 |
function the_author_url() { |
|---|
| 79 |
echo get_the_author_url(); |
|---|
| 80 |
} |
|---|
| 81 |
|
|---|
| 82 |
function get_the_author_icq() { |
|---|
| 83 |
global $id,$authordata; return $authordata->user_icq; |
|---|
| 84 |
} |
|---|
| 85 |
function the_author_icq() { |
|---|
| 86 |
echo get_the_author_icq(); |
|---|
| 87 |
} |
|---|
| 88 |
|
|---|
| 89 |
function get_the_author_aim() { |
|---|
| 90 |
global $id,$authordata; return str_replace(' ', '+', $authordata->user_aim); |
|---|
| 91 |
} |
|---|
| 92 |
function the_author_aim() { |
|---|
| 93 |
echo get_the_author_aim(); |
|---|
| 94 |
} |
|---|
| 95 |
|
|---|
| 96 |
function get_the_author_yim() { |
|---|
| 97 |
global $id,$authordata; return $authordata->user_yim; |
|---|
| 98 |
} |
|---|
| 99 |
function the_author_yim() { |
|---|
| 100 |
echo get_the_author_yim(); |
|---|
| 101 |
} |
|---|
| 102 |
|
|---|
| 103 |
function get_the_author_msn() { |
|---|
| 104 |
global $id,$authordata; return $authordata->user_msn; |
|---|
| 105 |
} |
|---|
| 106 |
function the_author_msn() { |
|---|
| 107 |
echo get_the_author_msn(); |
|---|
| 108 |
} |
|---|
| 109 |
|
|---|
| 110 |
function get_the_author_posts() { |
|---|
| 111 |
global $id,$post; $posts=get_usernumposts($post->post_author); return $posts; |
|---|
| 112 |
} |
|---|
| 113 |
function the_author_posts() { |
|---|
| 114 |
echo get_the_author_posts(); |
|---|
| 115 |
} |
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 |
function the_author_posts_link($idmode='') { |
|---|
| 119 |
global $id, $authordata; |
|---|
| 120 |
|
|---|
| 121 |
echo '<a href="' . get_author_link(0, $authordata->ID, $authordata->user_nicename) . '" title="' . sprintf(__("Posts by %s"), wp_specialchars(the_author($idmode, false))) . '">' . the_author($idmode, false) . '</a>'; |
|---|
| 122 |
} |
|---|
| 123 |
|
|---|
| 124 |
|
|---|
| 125 |
function get_author_link($echo = false, $author_id, $author_nicename) { |
|---|
| 126 |
global $wpdb, $wp_rewrite, $post, $cache_userdata; |
|---|
| 127 |
$auth_ID = $author_id; |
|---|
| 128 |
$link = $wp_rewrite->get_author_permastruct(); |
|---|
| 129 |
|
|---|
| 130 |
if (empty($link)) { |
|---|
| 131 |
$file = get_settings('home') . '/'; |
|---|
| 132 |
$link = $file . '?author=' . $auth_ID; |
|---|
| 133 |
} else { |
|---|
| 134 |
if ('' == $author_nicename) $author_nicename = $cache_userdata[$author_id]->author_nicename; |
|---|
| 135 |
$link = str_replace('%author%', $author_nicename, $link); |
|---|
| 136 |
$link = get_settings('home') . trailingslashit($link); |
|---|
| 137 |
} |
|---|
| 138 |
|
|---|
| 139 |
$link = apply_filters('author_link', $link, $author_id, $author_nicename); |
|---|
| 140 |
if ($echo) echo $link; |
|---|
| 141 |
return $link; |
|---|
| 142 |
} |
|---|
| 143 |
|
|---|
| 144 |
function wp_list_authors($args = '') { |
|---|
| 145 |
parse_str($args, $r); |
|---|
| 146 |
if (!isset($r['optioncount'])) $r['optioncount'] = false; |
|---|
| 147 |
if (!isset($r['exclude_admin'])) $r['exclude_admin'] = true; |
|---|
| 148 |
if (!isset($r['show_fullname'])) $r['show_fullname'] = false; |
|---|
| 149 |
if (!isset($r['hide_empty'])) $r['hide_empty'] = true; |
|---|
| 150 |
if (!isset($r['feed'])) $r['feed'] = ''; |
|---|
| 151 |
if (!isset($r['feed_image'])) $r['feed_image'] = ''; |
|---|
| 152 |
|
|---|
| 153 |
list_authors($r['optioncount'], $r['exclude_admin'], $r['show_fullname'], $r['hide_empty'], $r['feed'], $r['feed_image']); |
|---|
| 154 |
} |
|---|
| 155 |
|
|---|
| 156 |
function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') { |
|---|
| 157 |
global $wpdb; |
|---|
| 158 |
|
|---|
| 159 |
$query = "SELECT ID, user_nickname, user_firstname, user_lastname, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY user_nickname"; |
|---|
| 160 |
$authors = $wpdb->get_results($query); |
|---|
| 161 |
|
|---|
| 162 |
foreach($authors as $author) { |
|---|
| 163 |
$posts = get_usernumposts($author->ID); |
|---|
| 164 |
$name = $author->user_nickname; |
|---|
| 165 |
|
|---|
| 166 |
if ($show_fullname && ($author->user_firstname != '' && $author->user_lastname != '')) { |
|---|
| 167 |
$name = "$author->user_firstname $author->user_lastname"; |
|---|
| 168 |
} |
|---|
| 169 |
|
|---|
| 170 |
if (! ($posts == 0 && $hide_empty)) echo "<li>"; |
|---|
| 171 |
if ($posts == 0) { |
|---|
| 172 |
if ( !$hide_empty ) |
|---|
| 173 |
$link = $name; |
|---|
| 174 |
} else { |
|---|
| 175 |
$link = '<a href="' . get_author_link(0, $author->ID, $author->user_nicename) . '" title="' . sprintf(__("Posts by %s"), wp_specialchars($author->user_nickname)) . '">' . $name . '</a>'; |
|---|
| 176 |
|
|---|
| 177 |
if ( (! empty($feed_image)) || (! empty($feed)) ) { |
|---|
| 178 |
|
|---|
| 179 |
$link .= ' '; |
|---|
| 180 |
|
|---|
| 181 |
if (empty($feed_image)) { |
|---|
| 182 |
$link .= '('; |
|---|
| 183 |
} |
|---|
| 184 |
|
|---|
| 185 |
$link .= '<a href="' . get_author_rss_link(0, $author->ID, $author->user_nicename) . '"'; |
|---|
| 186 |
|
|---|
| 187 |
if (! empty($feed)) { |
|---|
| 188 |
$title = ' title="' . $feed . '"'; |
|---|
| 189 |
$alt = ' alt="' . $feed . '"'; |
|---|
| 190 |
$name = $feed; |
|---|
| 191 |
$link .= $title; |
|---|
| 192 |
} |
|---|
| 193 |
|
|---|
| 194 |
$link .= '>'; |
|---|
| 195 |
|
|---|
| 196 |
if (! empty($feed_image)) { |
|---|
| 197 |
$link .= "<img src=\"$feed_image\" border=\"0\"$alt$title" . ' />'; |
|---|
| 198 |
} else { |
|---|
| 199 |
$link .= $name; |
|---|
| 200 |
} |
|---|
| 201 |
|
|---|
| 202 |
$link .= '</a>'; |
|---|
| 203 |
|
|---|
| 204 |
if (empty($feed_image)) { |
|---|
| 205 |
$link .= ')'; |
|---|
| 206 |
} |
|---|
| 207 |
} |
|---|
| 208 |
|
|---|
| 209 |
if ($optioncount) { |
|---|
| 210 |
$link .= ' ('. $posts . ')'; |
|---|
| 211 |
} |
|---|
| 212 |
} |
|---|
| 213 |
|
|---|
| 214 |
if (! ($posts == 0 && $hide_empty)) echo "$link</li>"; |
|---|
| 215 |
} |
|---|
| 216 |
} |
|---|
| 217 |
|
|---|
| 218 |
?> |
|---|