| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
function get_the_author($deprecated = '') { |
|---|
| 10 |
global $authordata; |
|---|
| 11 |
return apply_filters('the_author', $authordata->display_name); |
|---|
| 12 |
} |
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
function the_author($deprecated = '', $deprecated_echo = true) { |
|---|
| 22 |
if ( $deprecated_echo ) |
|---|
| 23 |
echo get_the_author(); |
|---|
| 24 |
return get_the_author(); |
|---|
| 25 |
} |
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
function get_the_author_description() { |
|---|
| 33 |
global $authordata; |
|---|
| 34 |
return $authordata->description; |
|---|
| 35 |
} |
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
function the_author_description() { |
|---|
| 43 |
echo get_the_author_description(); |
|---|
| 44 |
} |
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
function get_the_author_login() { |
|---|
| 52 |
global $authordata; |
|---|
| 53 |
return $authordata->user_login; |
|---|
| 54 |
} |
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
function the_author_login() { |
|---|
| 62 |
echo get_the_author_login(); |
|---|
| 63 |
} |
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
function get_the_author_firstname() { |
|---|
| 71 |
global $authordata; |
|---|
| 72 |
return $authordata->first_name; |
|---|
| 73 |
} |
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
function the_author_firstname() { |
|---|
| 81 |
echo get_the_author_firstname(); |
|---|
| 82 |
} |
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
function get_the_author_lastname() { |
|---|
| 90 |
global $authordata; |
|---|
| 91 |
return $authordata->last_name; |
|---|
| 92 |
} |
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
function the_author_lastname() { |
|---|
| 100 |
echo get_the_author_lastname(); |
|---|
| 101 |
} |
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
function get_the_author_nickname() { |
|---|
| 109 |
global $authordata; |
|---|
| 110 |
return $authordata->nickname; |
|---|
| 111 |
} |
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 |
function the_author_nickname() { |
|---|
| 119 |
echo get_the_author_nickname(); |
|---|
| 120 |
} |
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 |
|
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 |
function get_the_author_ID() { |
|---|
| 128 |
global $authordata; |
|---|
| 129 |
return (int) $authordata->ID; |
|---|
| 130 |
} |
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 |
function the_author_ID() { |
|---|
| 138 |
echo get_the_author_id(); |
|---|
| 139 |
} |
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 |
function get_the_author_email() { |
|---|
| 147 |
global $authordata; |
|---|
| 148 |
return $authordata->user_email; |
|---|
| 149 |
} |
|---|
| 150 |
|
|---|
| 151 |
|
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 |
|
|---|
| 155 |
|
|---|
| 156 |
function the_author_email() { |
|---|
| 157 |
echo apply_filters('the_author_email', get_the_author_email() ); |
|---|
| 158 |
} |
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 |
|
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 |
|
|---|
| 165 |
function get_the_author_url() { |
|---|
| 166 |
global $authordata; |
|---|
| 167 |
|
|---|
| 168 |
if ( 'http://' == $authordata->user_url ) |
|---|
| 169 |
return ''; |
|---|
| 170 |
|
|---|
| 171 |
return $authordata->user_url; |
|---|
| 172 |
} |
|---|
| 173 |
|
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| 176 |
|
|---|
| 177 |
|
|---|
| 178 |
|
|---|
| 179 |
function the_author_url() { |
|---|
| 180 |
echo get_the_author_url(); |
|---|
| 181 |
} |
|---|
| 182 |
|
|---|
| 183 |
|
|---|
| 184 |
|
|---|
| 185 |
|
|---|
| 186 |
|
|---|
| 187 |
|
|---|
| 188 |
|
|---|
| 189 |
function the_author_link() { |
|---|
| 190 |
if (get_the_author_url()) { |
|---|
| 191 |
echo '<a href="' . get_the_author_url() . '" title="' . sprintf(__("Visit %s's website"), get_the_author()) . '" rel="external">' . get_the_author() . '</a>'; |
|---|
| 192 |
} else { |
|---|
| 193 |
the_author(); |
|---|
| 194 |
} |
|---|
| 195 |
} |
|---|
| 196 |
|
|---|
| 197 |
|
|---|
| 198 |
|
|---|
| 199 |
|
|---|
| 200 |
|
|---|
| 201 |
|
|---|
| 202 |
function get_the_author_icq() { |
|---|
| 203 |
global $authordata; |
|---|
| 204 |
return $authordata->icq; |
|---|
| 205 |
} |
|---|
| 206 |
|
|---|
| 207 |
|
|---|
| 208 |
|
|---|
| 209 |
|
|---|
| 210 |
|
|---|
| 211 |
|
|---|
| 212 |
function the_author_icq() { |
|---|
| 213 |
echo get_the_author_icq(); |
|---|
| 214 |
} |
|---|
| 215 |
|
|---|
| 216 |
|
|---|
| 217 |
|
|---|
| 218 |
|
|---|
| 219 |
|
|---|
| 220 |
|
|---|
| 221 |
function get_the_author_aim() { |
|---|
| 222 |
global $authordata; |
|---|
| 223 |
return str_replace(' ', '+', $authordata->aim); |
|---|
| 224 |
} |
|---|
| 225 |
|
|---|
| 226 |
|
|---|
| 227 |
|
|---|
| 228 |
|
|---|
| 229 |
|
|---|
| 230 |
|
|---|
| 231 |
function the_author_aim() { |
|---|
| 232 |
echo get_the_author_aim(); |
|---|
| 233 |
} |
|---|
| 234 |
|
|---|
| 235 |
|
|---|
| 236 |
|
|---|
| 237 |
|
|---|
| 238 |
|
|---|
| 239 |
|
|---|
| 240 |
function get_the_author_yim() { |
|---|
| 241 |
global $authordata; |
|---|
| 242 |
return $authordata->yim; |
|---|
| 243 |
} |
|---|
| 244 |
|
|---|
| 245 |
|
|---|
| 246 |
|
|---|
| 247 |
|
|---|
| 248 |
|
|---|
| 249 |
|
|---|
| 250 |
function the_author_yim() { |
|---|
| 251 |
echo get_the_author_yim(); |
|---|
| 252 |
} |
|---|
| 253 |
|
|---|
| 254 |
|
|---|
| 255 |
|
|---|
| 256 |
|
|---|
| 257 |
|
|---|
| 258 |
|
|---|
| 259 |
function get_the_author_msn() { |
|---|
| 260 |
global $authordata; |
|---|
| 261 |
return $authordata->msn; |
|---|
| 262 |
} |
|---|
| 263 |
|
|---|
| 264 |
|
|---|
| 265 |
|
|---|
| 266 |
|
|---|
| 267 |
|
|---|
| 268 |
|
|---|
| 269 |
function the_author_msn() { |
|---|
| 270 |
echo get_the_author_msn(); |
|---|
| 271 |
} |
|---|
| 272 |
|
|---|
| 273 |
|
|---|
| 274 |
|
|---|
| 275 |
|
|---|
| 276 |
|
|---|
| 277 |
|
|---|
| 278 |
|
|---|
| 279 |
function get_the_author_posts() { |
|---|
| 280 |
global $post; |
|---|
| 281 |
return get_usernumposts($post->post_author); |
|---|
| 282 |
} |
|---|
| 283 |
|
|---|
| 284 |
|
|---|
| 285 |
|
|---|
| 286 |
|
|---|
| 287 |
|
|---|
| 288 |
|
|---|
| 289 |
function the_author_posts() { |
|---|
| 290 |
echo get_the_author_posts(); |
|---|
| 291 |
} |
|---|
| 292 |
|
|---|
| 293 |
|
|---|
| 294 |
|
|---|
| 295 |
|
|---|
| 296 |
|
|---|
| 297 |
|
|---|
| 298 |
|
|---|
| 299 |
|
|---|
| 300 |
|
|---|
| 301 |
function the_author_posts_link($deprecated = '') { |
|---|
| 302 |
global $authordata; |
|---|
| 303 |
printf( |
|---|
| 304 |
'<a href="%1$s" title="%2$s">%3$s</a>', |
|---|
| 305 |
get_author_posts_url( $authordata->ID, $authordata->user_nicename ), |
|---|
| 306 |
sprintf( __( 'Posts by %s' ), attribute_escape( get_the_author() ) ), |
|---|
| 307 |
get_the_author() |
|---|
| 308 |
); |
|---|
| 309 |
} |
|---|
| 310 |
|
|---|
| 311 |
|
|---|
| 312 |
|
|---|
| 313 |
|
|---|
| 314 |
|
|---|
| 315 |
|
|---|
| 316 |
|
|---|
| 317 |
|
|---|
| 318 |
function get_author_posts_url($author_id, $author_nicename = '') { |
|---|
| 319 |
global $wpdb, $wp_rewrite, $post; |
|---|
| 320 |
$auth_ID = (int) $author_id; |
|---|
| 321 |
$link = $wp_rewrite->get_author_permastruct(); |
|---|
| 322 |
|
|---|
| 323 |
if ( empty($link) ) { |
|---|
| 324 |
$file = get_option('home') . '/'; |
|---|
| 325 |
$link = $file . '?author=' . $auth_ID; |
|---|
| 326 |
} else { |
|---|
| 327 |
if ( '' == $author_nicename ) { |
|---|
| 328 |
$user = get_userdata($author_id); |
|---|
| 329 |
if ( !empty($user->user_nicename) ) |
|---|
| 330 |
$author_nicename = $user->user_nicename; |
|---|
| 331 |
} |
|---|
| 332 |
$link = str_replace('%author%', $author_nicename, $link); |
|---|
| 333 |
$link = get_option('home') . trailingslashit($link); |
|---|
| 334 |
} |
|---|
| 335 |
|
|---|
| 336 |
$link = apply_filters('author_link', $link, $author_id, $author_nicename); |
|---|
| 337 |
|
|---|
| 338 |
return $link; |
|---|
| 339 |
} |
|---|
| 340 |
|
|---|
| 341 |
|
|---|
| 342 |
|
|---|
| 343 |
|
|---|
| 344 |
|
|---|
| 345 |
|
|---|
| 346 |
function get_author_name( $auth_id ) { |
|---|
| 347 |
$authordata = get_userdata( $auth_id ); |
|---|
| 348 |
return $authordata->display_name; |
|---|
| 349 |
} |
|---|
| 350 |
|
|---|
| 351 |
|
|---|
| 352 |
|
|---|
| 353 |
|
|---|
| 354 |
|
|---|
| 355 |
|
|---|
| 356 |
|
|---|
| 357 |
|
|---|
| 358 |
|
|---|
| 359 |
|
|---|
| 360 |
|
|---|
| 361 |
|
|---|
| 362 |
|
|---|
| 363 |
function wp_list_authors($args = '') { |
|---|
| 364 |
global $wpdb; |
|---|
| 365 |
|
|---|
| 366 |
$defaults = array( |
|---|
| 367 |
'optioncount' => false, 'exclude_admin' => true, |
|---|
| 368 |
'show_fullname' => false, 'hide_empty' => true, |
|---|
| 369 |
'feed' => '', 'feed_image' => '', 'echo' => true |
|---|
| 370 |
); |
|---|
| 371 |
|
|---|
| 372 |
$r = wp_parse_args( $args, $defaults ); |
|---|
| 373 |
extract($r, EXTR_SKIP); |
|---|
| 374 |
|
|---|
| 375 |
$return = ''; |
|---|
| 376 |
|
|---|
| 377 |
|
|---|
| 378 |
$authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name"); |
|---|
| 379 |
|
|---|
| 380 |
$author_count = array(); |
|---|
| 381 |
foreach ((array) $wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql( 'post' ) . " GROUP BY post_author") as $row) { |
|---|
| 382 |
$author_count[$row->post_author] = $row->count; |
|---|
| 383 |
} |
|---|
| 384 |
|
|---|
| 385 |
foreach ( (array) $authors as $author ) { |
|---|
| 386 |
$author = get_userdata( $author->ID ); |
|---|
| 387 |
$posts = (isset($author_count[$author->ID])) ? $author_count[$author->ID] : 0; |
|---|
| 388 |
$name = $author->display_name; |
|---|
| 389 |
|
|---|
| 390 |
if ( $show_fullname && ($author->first_name != '' && $author->last_name != '') ) |
|---|
| 391 |
$name = "$author->first_name $author->last_name"; |
|---|
| 392 |
|
|---|
| 393 |
if ( !($posts == 0 && $hide_empty) ) |
|---|
| 394 |
$return .= '<li>'; |
|---|
| 395 |
if ( $posts == 0 ) { |
|---|
| 396 |
if ( !$hide_empty ) |
|---|
| 397 |
$link = $name; |
|---|
| 398 |
} else { |
|---|
| 399 |
$link = '<a href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" title="' . sprintf(__("Posts by %s"), attribute_escape($author->display_name)) . '">' . $name . '</a>'; |
|---|
| 400 |
|
|---|
| 401 |
if ( (! empty($feed_image)) || (! empty($feed)) ) { |
|---|
| 402 |
$link .= ' '; |
|---|
| 403 |
if (empty($feed_image)) |
|---|
| 404 |
$link .= '('; |
|---|
| 405 |
$link .= '<a href="' . get_author_rss_link(0, $author->ID, $author->user_nicename) . '"'; |
|---|
| 406 |
|
|---|
| 407 |
if ( !empty($feed) ) { |
|---|
| 408 |
$title = ' title="' . $feed . '"'; |
|---|
| 409 |
$alt = ' alt="' . $feed . '"'; |
|---|
| 410 |
$name = $feed; |
|---|
| 411 |
$link .= $title; |
|---|
| 412 |
} |
|---|
| 413 |
|
|---|
| 414 |
$link .= '>'; |
|---|
| 415 |
|
|---|
| 416 |
if ( !empty($feed_image) ) |
|---|
| 417 |
$link .= "<img src=\"$feed_image\" border=\"0\"$alt$title" . ' />'; |
|---|
| 418 |
else |
|---|
| 419 |
$link .= $name; |
|---|
| 420 |
|
|---|
| 421 |
$link .= '</a>'; |
|---|
| 422 |
|
|---|
| 423 |
if ( empty($feed_image) ) |
|---|
| 424 |
$link .= ')'; |
|---|
| 425 |
} |
|---|
| 426 |
|
|---|
| 427 |
if ( $optioncount ) |
|---|
| 428 |
$link .= ' ('. $posts . ')'; |
|---|
| 429 |
|
|---|
| 430 |
} |
|---|
| 431 |
|
|---|
| 432 |
if ( !($posts == 0 && $hide_empty) ) |
|---|
| 433 |
$return .= $link . '</li>'; |
|---|
| 434 |
} |
|---|
| 435 |
if ( !$echo ) |
|---|
| 436 |
return $return; |
|---|
| 437 |
echo $return; |
|---|
| 438 |
} |
|---|
| 439 |
|
|---|
| 440 |
?> |
|---|
| 441 |
|
|---|