Changeset 15620
- Timestamp:
- 09/15/2010 07:52:25 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/author-template.php
r15567 r15620 258 258 * <li>style (string) ('list'): Whether to display list of authors in list form 259 259 * or as a string.</li> 260 * <li>html (bool) (true): Whether to list the items in html for or plaintext.260 * <li>html (bool) (true): Whether to list the items in html form or plaintext. 261 261 * </li> 262 262 * </ul> … … 271 271 272 272 $defaults = array( 273 'orderby' => 'name', 'order' => 'ASC', 'number' => '', 273 274 'optioncount' => false, 'exclude_admin' => true, 274 275 'show_fullname' => false, 'hide_empty' => true, … … 277 278 ); 278 279 279 $r = wp_parse_args( $args, $defaults ); 280 extract($r, EXTR_SKIP); 280 $args = wp_parse_args( $args, $defaults ); 281 extract( $args, EXTR_SKIP ); 282 281 283 $return = ''; 282 284 283 /** @todo Move select to get_authors(). */ 284 $users = get_users(); 285 $author_ids = array(); 286 foreach ( (array) $users as $user ) 287 $author_ids[] = $user->user_id; 288 if ( count($author_ids) > 0 ) { 289 $author_ids = implode(',', $author_ids ); 290 $authors = $wpdb->get_results( "SELECT ID, user_nicename from $wpdb->users WHERE ID IN($author_ids) " . ($exclude_admin ? "AND user_login <> 'admin' " : '') . "ORDER BY display_name" ); 291 } else { 292 $authors = array(); 293 } 285 $authors = get_users( wp_array_slice_assoc( $args, array( 'orderby', 'order', 'number' ) ) ); 294 286 295 287 $author_count = array(); … … 297 289 $author_count[$row->post_author] = $row->count; 298 290 299 foreach ( (array) $authors as $author ) { 291 foreach ( $authors as $author ) { 292 293 if ( $exclude_admin && 'admin' == $author->display_name ) 294 continue; 295 296 $posts = isset( $author_count[$author->ID] ) ? $author_count[$author->ID] : 0; 297 298 if ( !$posts && $hide_empty ) 299 continue; 300 300 301 301 $link = ''; 302 302 303 $author = get_userdata( $author->ID ); 304 $posts = (isset($author_count[$author->ID])) ? $author_count[$author->ID] : 0; 305 $name = $author->display_name; 306 307 if ( $show_fullname && ($author->first_name != '' && $author->last_name != '') ) 303 if ( $show_fullname && $author->first_name && $author->last_name ) 308 304 $name = "$author->first_name $author->last_name"; 309 310 if( !$html ) { 311 if ( $posts == 0 ) { 312 if ( ! $hide_empty ) 313 $return .= $name . ', '; 314 } else 315 $return .= $name . ', '; 316 317 // No need to go further to process HTML. 318 continue; 305 else 306 $name = $author->display_name; 307 308 if ( !$html ) { 309 $return .= $name . ', '; 310 311 continue; // No need to go further to process HTML. 319 312 } 320 313 321 if ( !($posts == 0 && $hide_empty) && 'list' == $style )314 if ( 'list' == $style ) { 322 315 $return .= '<li>'; 323 if ( $posts == 0 ) { 324 if ( ! $hide_empty ) 325 $link = $name; 326 } else { 327 $link = '<a href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" title="' . esc_attr( sprintf(__("Posts by %s"), $author->display_name) ) . '">' . $name . '</a>'; 328 329 if ( (! empty($feed_image)) || (! empty($feed)) ) { 330 $link .= ' '; 331 if (empty($feed_image)) 332 $link .= '('; 333 $link .= '<a href="' . get_author_feed_link($author->ID) . '"'; 334 335 if ( !empty($feed) ) { 336 $title = ' title="' . esc_attr($feed) . '"'; 337 $alt = ' alt="' . esc_attr($feed) . '"'; 338 $name = $feed; 339 $link .= $title; 340 } 341 342 $link .= '>'; 343 344 if ( !empty($feed_image) ) 345 $link .= "<img src=\"" . esc_url($feed_image) . "\" style=\"border: none;\"$alt$title" . ' />'; 346 else 347 $link .= $name; 348 349 $link .= '</a>'; 350 351 if ( empty($feed_image) ) 352 $link .= ')'; 316 } 317 318 $link = '<a href="' . get_author_posts_url( $author->ID, $author->user_nicename ) . '" title="' . esc_attr( sprintf(__("Posts by %s"), $author->display_name) ) . '">' . $name . '</a>'; 319 320 if ( !empty( $feed_image ) || !empty( $feed ) ) { 321 $link .= ' '; 322 if ( empty( $feed_image ) ) { 323 $link .= '('; 353 324 } 354 325 355 if ( $optioncount ) 356 $link .= ' ('. $posts . ')'; 357 326 $link .= '<a href="' . get_author_feed_link( $author->ID ) . '"'; 327 328 $alt = $title = ''; 329 if ( !empty( $feed ) ) { 330 $title = ' title="' . esc_attr( $feed ) . '"'; 331 $alt = ' alt="' . esc_attr( $feed ) . '"'; 332 $name = $feed; 333 $link .= $title; 334 } 335 336 $link .= '>'; 337 338 if ( !empty( $feed_image ) ) 339 $link .= '<img src="' . esc_url( $feed_image ) . '" style="border: none;"' . $alt . $title . ' />'; 340 else 341 $link .= $name; 342 343 $link .= '</a>'; 344 345 if ( empty( $feed_image ) ) 346 $link .= ')'; 358 347 } 359 348 360 if ( $posts || ! $hide_empty ) 361 $return .= $link . ( ( 'list' == $style ) ? '</li>' : ', ' ); 349 if ( $optioncount ) 350 $link .= ' ('. $posts . ')'; 351 352 $return .= $link; 353 $return .= ( 'list' == $style ) ? '</li>' : ', '; 362 354 } 363 355 364 $return = trim($return, ', ');365 366 if ( ! 356 $return = rtrim($return, ', '); 357 358 if ( !$echo ) 367 359 return $return; 360 368 361 echo $return; 369 362 }
Note: See TracChangeset
for help on using the changeset viewer.