-
+ 4F49BD3019F35C5B05F45C0AE981922841C909DB6E655DA81DE3BF0082A1A7A00563F3E9F43CD22D8098C745D0F6656B57DF1A8B0CD0BB4DDB3E18FBB4A78910mp-wp/wp-includes/author-template.php(0 . 0)(1 . 537)
71218 <?php
71219 /**
71220 * Author Template functions for use in themes.
71221 *
71222 * These functions must be used within the WordPress Loop.
71223 *
71224 * @link http://codex.wordpress.org/Author_Templates
71225 *
71226 * @package WordPress
71227 * @subpackage Template
71228 */
71229
71230 /**
71231 * Retrieve the author of the current post.
71232 *
71233 * @since 1.5
71234 * @uses $authordata The current author's DB object.
71235 * @uses apply_filters() Calls 'the_author' hook on the author display name.
71236 *
71237 * @param string $deprecated Deprecated.
71238 * @return string The author's display name.
71239 */
71240 function get_the_author($deprecated = '') {
71241 global $authordata;
71242 return apply_filters('the_author', $authordata->display_name);
71243 }
71244
71245 /**
71246 * Display the name of the author of the current post.
71247 *
71248 * The behavior of this function is based off of old functionality predating
71249 * get_the_author(). This function is not deprecated, but is designed to echo
71250 * the value from get_the_author() and as an result of any old theme that might
71251 * still use the old behavior will also pass the value from get_the_author().
71252 *
71253 * The normal, expected behavior of this function is to echo the author and not
71254 * return it. However, backwards compatiability has to be maintained.
71255 *
71256 * @since 0.71
71257 * @see get_the_author()
71258 * @link http://codex.wordpress.org/Template_Tags/the_author
71259 *
71260 * @param string $deprecated Deprecated.
71261 * @param string $deprecated_echo Echo the string or return it.
71262 * @return string The author's display name, from get_the_author().
71263 */
71264 function the_author($deprecated = '', $deprecated_echo = true) {
71265 if ( $deprecated_echo )
71266 echo get_the_author();
71267 return get_the_author();
71268 }
71269
71270 /**
71271 * Retrieve the description of the author of the current post.
71272 *
71273 * @since 1.5
71274 * @uses $authordata The current author's DB object.
71275 * @return string The author's description.
71276 */
71277 function get_the_author_description() {
71278 global $authordata;
71279 return $authordata->description;
71280 }
71281
71282 /**
71283 * Display the description of the author of the current post.
71284 *
71285 * @link http://codex.wordpress.org/Template_Tags/the_author_description
71286 * @since 1.0.0
71287 * @see get_the_author_description()
71288 */
71289 function the_author_description() {
71290 echo get_the_author_description();
71291 }
71292
71293 /**
71294 * Retrieve the login name of the author of the current post.
71295 *
71296 * @since 1.5
71297 * @uses $authordata The current author's DB object.
71298 * @return string The author's login name (username).
71299 */
71300 function get_the_author_login() {
71301 global $authordata;
71302 return $authordata->user_login;
71303 }
71304
71305 /**
71306 * Display the login name of the author of the current post.
71307 *
71308 * @link http://codex.wordpress.org/Template_Tags/the_author_login
71309 * @since 0.71
71310 * @see get_the_author_login()
71311 */
71312 function the_author_login() {
71313 echo get_the_author_login();
71314 }
71315
71316 /**
71317 * Retrieve the first name of the author of the current post.
71318 *
71319 * @since 1.5
71320 * @uses $authordata The current author's DB object.
71321 * @return string The author's first name.
71322 */
71323 function get_the_author_firstname() {
71324 global $authordata;
71325 return $authordata->first_name;
71326 }
71327
71328 /**
71329 * Display the first name of the author of the current post.
71330 *
71331 * @link http://codex.wordpress.org/Template_Tags/the_author_firstname
71332 * @since 0.71
71333 * @uses get_the_author_firstname()
71334 */
71335 function the_author_firstname() {
71336 echo get_the_author_firstname();
71337 }
71338
71339 /**
71340 * Retrieve the last name of the author of the current post.
71341 *
71342 * @since 1.5
71343 * @uses $authordata The current author's DB object.
71344 * @return string The author's last name.
71345 */
71346 function get_the_author_lastname() {
71347 global $authordata;
71348 return $authordata->last_name;
71349 }
71350
71351 /**
71352 * Display the last name of the author of the current post.
71353 *
71354 * @link http://codex.wordpress.org/Template_Tags/the_author_lastname
71355 * @since 0.71
71356 * @uses get_the_author_lastname()
71357 */
71358 function the_author_lastname() {
71359 echo get_the_author_lastname();
71360 }
71361
71362 /**
71363 * Retrieve the nickname of the author of the current post.
71364 *
71365 * @since 1.5
71366 * @uses $authordata The current author's DB object.
71367 * @return string The author's nickname.
71368 */
71369 function get_the_author_nickname() {
71370 global $authordata;
71371 return $authordata->nickname;
71372 }
71373
71374 /**
71375 * Display the nickname of the author of the current post.
71376 *
71377 * @link http://codex.wordpress.org/Template_Tags/the_author_nickname
71378 * @since 0.71
71379 * @uses get_the_author_nickname()
71380 */
71381 function the_author_nickname() {
71382 echo get_the_author_nickname();
71383 }
71384
71385 /**
71386 * Retrieve the ID of the author of the current post.
71387 *
71388 * @since 1.5
71389 * @uses $authordata The current author's DB object.
71390 * @return int The author's ID.
71391 */
71392 function get_the_author_ID() {
71393 global $authordata;
71394 return (int) $authordata->ID;
71395 }
71396
71397 /**
71398 * Display the ID of the author of the current post.
71399 *
71400 * @link http://codex.wordpress.org/Template_Tags/the_author_ID
71401 * @since 0.71
71402 * @uses get_the_author_ID()
71403 */
71404 function the_author_ID() {
71405 echo get_the_author_id();
71406 }
71407
71408 /**
71409 * Retrieve the email of the author of the current post.
71410 *
71411 * @since 1.5
71412 * @uses $authordata The current author's DB object.
71413 * @return string The author's username.
71414 */
71415 function get_the_author_email() {
71416 global $authordata;
71417 return $authordata->user_email;
71418 }
71419
71420 /**
71421 * Display the email of the author of the current post.
71422 *
71423 * @link http://codex.wordpress.org/Template_Tags/the_author_email
71424 * @since 0.71
71425 * @uses get_the_author_email()
71426 */
71427 function the_author_email() {
71428 echo apply_filters('the_author_email', get_the_author_email() );
71429 }
71430
71431 /**
71432 * Retrieve the URL to the home page of the author of the current post.
71433 *
71434 * @since 1.5
71435 * @uses $authordata The current author's DB object.
71436 * @return string The URL to the author's page.
71437 */
71438 function get_the_author_url() {
71439 global $authordata;
71440
71441 if ( 'http://' == $authordata->user_url )
71442 return '';
71443
71444 return $authordata->user_url;
71445 }
71446
71447 /**
71448 * Display the URL to the home page of the author of the current post.
71449 *
71450 * @link http://codex.wordpress.org/Template_Tags/the_author_url
71451 * @since 0.71
71452 * @uses get_the_author_url()
71453 */
71454 function the_author_url() {
71455 echo get_the_author_url();
71456 }
71457
71458 /**
71459 * Display either author's link or author's name.
71460 *
71461 * If the author has a home page set, echo an HTML link, otherwise just echo the
71462 * author's name.
71463 *
71464 * @link http://codex.wordpress.org/Template_Tags/the_author_link
71465 * @since 2.1
71466 * @uses get_the_author_url()
71467 * @uses the_author()
71468 */
71469 function the_author_link() {
71470 if (get_the_author_url()) {
71471 echo '<a href="' . get_the_author_url() . '" title="' . sprintf(__("Visit %s's website"), get_the_author()) . '" rel="external">' . get_the_author() . '</a>';
71472 } else {
71473 the_author();
71474 }
71475 }
71476
71477 /**
71478 * Retrieve the ICQ number of the author of the current post.
71479 *
71480 * @since 1.5
71481 * @uses $authordata The current author's DB object.
71482 * @return string The author's ICQ number.
71483 */
71484 function get_the_author_icq() {
71485 global $authordata;
71486 return $authordata->icq;
71487 }
71488
71489 /**
71490 * Display the ICQ number of the author of the current post.
71491 *
71492 * @link http://codex.wordpress.org/Template_Tags/the_author_icq
71493 * @since 0.71
71494 * @see get_the_author_icq()
71495 */
71496 function the_author_icq() {
71497 echo get_the_author_icq();
71498 }
71499
71500 /**
71501 * Retrieve the AIM name of the author of the current post.
71502 *
71503 * @since 1.5
71504 * @uses $authordata The current author's DB object.
71505 * @return string The author's AIM name.
71506 */
71507 function get_the_author_aim() {
71508 global $authordata;
71509 return str_replace(' ', '+', $authordata->aim);
71510 }
71511
71512 /**
71513 * Display the AIM name of the author of the current post.
71514 *
71515 * @link http://codex.wordpress.org/Template_Tags/the_author_aim
71516 * @since 0.71
71517 * @see get_the_author_aim()
71518 */
71519 function the_author_aim() {
71520 echo get_the_author_aim();
71521 }
71522
71523 /**
71524 * Retrieve the Yahoo! IM name of the author of the current post.
71525 *
71526 * @since 1.5
71527 * @uses $authordata The current author's DB object.
71528 * @return string The author's Yahoo! IM name.
71529 */
71530 function get_the_author_yim() {
71531 global $authordata;
71532 return $authordata->yim;
71533 }
71534
71535 /**
71536 * Display the Yahoo! IM name of the author of the current post.
71537 *
71538 * @link http://codex.wordpress.org/Template_Tags/the_author_yim
71539 * @since 0.71
71540 * @see get_the_author_yim()
71541 */
71542 function the_author_yim() {
71543 echo get_the_author_yim();
71544 }
71545
71546 /**
71547 * Retrieve the MSN address of the author of the current post.
71548 *
71549 * @since 1.5
71550 * @uses $authordata The current author's DB object.
71551 * @return string The author's MSN address.
71552 */
71553 function get_the_author_msn() {
71554 global $authordata;
71555 return $authordata->msn;
71556 }
71557
71558 /**
71559 * Display the MSN address of the author of the current post.
71560 *
71561 * @link http://codex.wordpress.org/Template_Tags/the_author_msn
71562 * @since 0.71
71563 * @see get_the_author_msn()
71564 */
71565 function the_author_msn() {
71566 echo get_the_author_msn();
71567 }
71568
71569 /**
71570 * Retrieve the number of posts by the author of the current post.
71571 *
71572 * @since 1.5
71573 * @uses $post The current post in the Loop's DB object.
71574 * @uses get_usernumposts()
71575 * @return int The number of posts by the author.
71576 */
71577 function get_the_author_posts() {
71578 global $post;
71579 return get_usernumposts($post->post_author);
71580 }
71581
71582 /**
71583 * Display the number of posts by the author of the current post.
71584 *
71585 * @link http://codex.wordpress.org/Template_Tags/the_author_posts
71586 * @since 0.71
71587 * @uses get_the_author_posts() Echos returned value from function.
71588 */
71589 function the_author_posts() {
71590 echo get_the_author_posts();
71591 }
71592
71593 /**
71594 * Display an HTML link to the author page of the author of the current post.
71595 *
71596 * Does just echo get_author_posts_url() function, like the others do. The
71597 * reason for this, is that another function is used to help in printing the
71598 * link to the author's posts.
71599 *
71600 * @link http://codex.wordpress.org/Template_Tags/the_author_posts_link
71601 * @since 1.2.0
71602 * @uses $authordata The current author's DB object.
71603 * @uses get_author_posts_url()
71604 * @uses get_the_author()
71605 * @param string $deprecated Deprecated.
71606 */
71607 function the_author_posts_link($deprecated = '') {
71608 global $authordata;
71609 printf(
71610 '<a href="%1$s" title="%2$s">%3$s</a>',
71611 get_author_posts_url( $authordata->ID, $authordata->user_nicename ),
71612 sprintf( __( 'Posts by %s' ), attribute_escape( get_the_author() ) ),
71613 get_the_author()
71614 );
71615 }
71616
71617 /**
71618 * Retrieve the URL to the author page of the author of the current post.
71619 *
71620 * @since 2.1.0
71621 * @uses $wp_rewrite WP_Rewrite
71622 * @return string The URL to the author's page.
71623 */
71624 function get_author_posts_url($author_id, $author_nicename = '') {
71625 global $wp_rewrite;
71626 $auth_ID = (int) $author_id;
71627 $link = $wp_rewrite->get_author_permastruct();
71628
71629 if ( empty($link) ) {
71630 $file = get_option('home') . '/';
71631 $link = $file . '?author=' . $auth_ID;
71632 } else {
71633 if ( '' == $author_nicename ) {
71634 $user = get_userdata($author_id);
71635 if ( !empty($user->user_nicename) )
71636 $author_nicename = $user->user_nicename;
71637 }
71638 $link = str_replace('%author%', $author_nicename, $link);
71639 $link = get_option('home') . trailingslashit($link);
71640 }
71641
71642 $link = apply_filters('author_link', $link, $author_id, $author_nicename);
71643
71644 return $link;
71645 }
71646
71647 /**
71648 * Retrieve the specified author's preferred display name.
71649 *
71650 * @since 1.0.0
71651 * @param int $auth_id The ID of the author.
71652 * @return string The author's display name.
71653 */
71654 function get_author_name( $auth_id ) {
71655 $authordata = get_userdata( $auth_id );
71656 return $authordata->display_name;
71657 }
71658
71659 /**
71660 * List all the authors of the blog, with several options available.
71661 *
71662 * optioncount (boolean) (false): Show the count in parenthesis next to the
71663 * author's name.
71664 * exclude_admin (boolean) (true): Exclude the 'admin' user that is installed by
71665 * default.
71666 * show_fullname (boolean) (false): Show their full names.
71667 * hide_empty (boolean) (true): Don't show authors without any posts.
71668 * feed (string) (''): If isn't empty, show links to author's feeds.
71669 * feed_image (string) (''): If isn't empty, use this image to link to feeds.
71670 * echo (boolean) (true): Set to false to return the output, instead of echoing.
71671 *
71672 * @link http://codex.wordpress.org/Template_Tags/wp_list_authors
71673 * @since 1.2.0
71674 * @param array $args The argument array.
71675 * @return null|string The output, if echo is set to false.
71676 */
71677 function wp_list_authors($args = '') {
71678 global $wpdb;
71679
71680 $defaults = array(
71681 'optioncount' => false, 'exclude_admin' => true,
71682 'show_fullname' => false, 'hide_empty' => true,
71683 'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true
71684 );
71685
71686 $r = wp_parse_args( $args, $defaults );
71687 extract($r, EXTR_SKIP);
71688
71689 $return = '';
71690
71691 /** @todo Move select to get_authors(). */
71692 $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name");
71693
71694 $author_count = array();
71695 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) {
71696 $author_count[$row->post_author] = $row->count;
71697 }
71698
71699 foreach ( (array) $authors as $author ) {
71700 $author = get_userdata( $author->ID );
71701 $posts = (isset($author_count[$author->ID])) ? $author_count[$author->ID] : 0;
71702 $name = $author->display_name;
71703
71704 if ( $show_fullname && ($author->first_name != '' && $author->last_name != '') )
71705 $name = "$author->first_name $author->last_name";
71706
71707 if ( !($posts == 0 && $hide_empty) )
71708 $return .= '<li>';
71709 if ( $posts == 0 ) {
71710 if ( !$hide_empty )
71711 $link = $name;
71712 } else {
71713 $link = '<a href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" title="' . sprintf(__("Posts by %s"), attribute_escape($author->display_name)) . '">' . $name . '</a>';
71714
71715 if ( (! empty($feed_image)) || (! empty($feed)) ) {
71716 $link .= ' ';
71717 if (empty($feed_image))
71718 $link .= '(';
71719 $link .= '<a href="' . get_author_feed_link($author->ID) . '"';
71720
71721 if ( !empty($feed) ) {
71722 $title = ' title="' . $feed . '"';
71723 $alt = ' alt="' . $feed . '"';
71724 $name = $feed;
71725 $link .= $title;
71726 }
71727
71728 $link .= '>';
71729
71730 if ( !empty($feed_image) )
71731 $link .= "<img src=\"$feed_image\" style=\"border: none;\"$alt$title" . ' />';
71732 else
71733 $link .= $name;
71734
71735 $link .= '</a>';
71736
71737 if ( empty($feed_image) )
71738 $link .= ')';
71739 }
71740
71741 if ( $optioncount )
71742 $link .= ' ('. $posts . ')';
71743
71744 }
71745
71746 if ( !($posts == 0 && $hide_empty) )
71747 $return .= $link . '</li>';
71748 }
71749 if ( !$echo )
71750 return $return;
71751 echo $return;
71752 }
71753
71754 ?>