Changeset 42343 for trunk/src/wp-includes/author-template.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/author-template.php (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/author-template.php
r42201 r42343 21 21 * @return string|null The author's display name. 22 22 */ 23 function get_the_author( $deprecated = '') {23 function get_the_author( $deprecated = '' ) { 24 24 global $authordata; 25 25 26 if ( ! empty( $deprecated ) )26 if ( ! empty( $deprecated ) ) { 27 27 _deprecated_argument( __FUNCTION__, '2.1.0' ); 28 } 28 29 29 30 /** … … 34 35 * @param string $authordata->display_name The author's display name. 35 36 */ 36 return apply_filters( 'the_author', is_object($authordata) ? $authordata->display_name : null);37 return apply_filters( 'the_author', is_object( $authordata ) ? $authordata->display_name : null ); 37 38 } 38 39 … … 62 63 63 64 if ( true !== $deprecated_echo ) { 64 _deprecated_argument( __FUNCTION__, '1.5.0', 65 _deprecated_argument( 66 __FUNCTION__, '1.5.0', 65 67 /* translators: %s: get_the_author() */ 66 sprintf( __( 'Use %s instead if you do not want the value echoed.' ), 68 sprintf( 69 __( 'Use %s instead if you do not want the value echoed.' ), 67 70 '<code>get_the_author()</code>' 68 71 ) … … 85 88 */ 86 89 function get_the_modified_author() { 87 if ( $last_id = get_post_meta( get_post()->ID, '_edit_last', true ) ) {88 $last_user = get_userdata( $last_id);90 if ( $last_id = get_post_meta( get_post()->ID, '_edit_last', true ) ) { 91 $last_user = get_userdata( $last_id ); 89 92 90 93 /** … … 95 98 * @param string $last_user->display_name The author's display name. 96 99 */ 97 return apply_filters( 'the_modified_author', $last_user->display_name);100 return apply_filters( 'the_modified_author', $last_user->display_name ); 98 101 } 99 102 } … … 162 165 } 163 166 164 if ( in_array( $field, array( 'login', 'pass', 'nicename', 'email', 'url', 'registered', 'activation_key', 'status' ) ) ) 167 if ( in_array( $field, array( 'login', 'pass', 'nicename', 'email', 'url', 'registered', 'activation_key', 'status' ) ) ) { 165 168 $field = 'user_' . $field; 169 } 166 170 167 171 $value = isset( $authordata->$field ) ? $authordata->$field : ''; … … 221 225 */ 222 226 function get_the_author_link() { 223 if ( get_the_author_meta('url') ) { 224 return sprintf( '<a href="%1$s" title="%2$s" rel="author external">%3$s</a>', 225 esc_url( get_the_author_meta('url') ), 227 if ( get_the_author_meta( 'url' ) ) { 228 return sprintf( 229 '<a href="%1$s" title="%2$s" rel="author external">%3$s</a>', 230 esc_url( get_the_author_meta( 'url' ) ), 226 231 /* translators: %s: author's display name */ 227 232 esc_attr( sprintf( __( 'Visit %s’s website' ), get_the_author() ) ), … … 289 294 } 290 295 291 $link = sprintf( '<a href="%1$s" title="%2$s" rel="author">%3$s</a>', 296 $link = sprintf( 297 '<a href="%1$s" title="%2$s" rel="author">%3$s</a>', 292 298 esc_url( get_author_posts_url( $authordata->ID, $authordata->user_nicename ) ), 293 299 /* translators: %s: author's display name */ … … 335 341 global $wp_rewrite; 336 342 $auth_ID = (int) $author_id; 337 $link = $wp_rewrite->get_author_permastruct();338 339 if ( empty( $link) ) {343 $link = $wp_rewrite->get_author_permastruct(); 344 345 if ( empty( $link ) ) { 340 346 $file = home_url( '/' ); 341 347 $link = $file . '?author=' . $auth_ID; 342 348 } else { 343 349 if ( '' == $author_nicename ) { 344 $user = get_userdata( $author_id);345 if ( ! empty($user->user_nicename) )350 $user = get_userdata( $author_id ); 351 if ( ! empty( $user->user_nicename ) ) { 346 352 $author_nicename = $user->user_nicename; 347 } 348 $link = str_replace('%author%', $author_nicename, $link); 353 } 354 } 355 $link = str_replace( '%author%', $author_nicename, $link ); 349 356 $link = home_url( user_trailingslashit( $link ) ); 350 357 } … … 403 410 404 411 $defaults = array( 405 'orderby' => 'name', 'order' => 'ASC', 'number' => '', 406 'optioncount' => false, 'exclude_admin' => true, 407 'show_fullname' => false, 'hide_empty' => true, 408 'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true, 409 'style' => 'list', 'html' => true, 'exclude' => '', 'include' => '' 412 'orderby' => 'name', 413 'order' => 'ASC', 414 'number' => '', 415 'optioncount' => false, 416 'exclude_admin' => true, 417 'show_fullname' => false, 418 'hide_empty' => true, 419 'feed' => '', 420 'feed_image' => '', 421 'feed_type' => '', 422 'echo' => true, 423 'style' => 'list', 424 'html' => true, 425 'exclude' => '', 426 'include' => '', 410 427 ); 411 428 … … 414 431 $return = ''; 415 432 416 $query_args = wp_array_slice_assoc( $args, array( 'orderby', 'order', 'number', 'exclude', 'include' ) );433 $query_args = wp_array_slice_assoc( $args, array( 'orderby', 'order', 'number', 'exclude', 'include' ) ); 417 434 $query_args['fields'] = 'ids'; 418 $authors = get_users( $query_args );435 $authors = get_users( $query_args ); 419 436 420 437 $author_count = array(); 421 foreach ( (array) $wpdb->get_results( "SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE " . get_private_posts_cap_sql( 'post' ) . " GROUP BY post_author") as $row ) {422 $author_count[ $row->post_author] = $row->count;438 foreach ( (array) $wpdb->get_results( "SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE " . get_private_posts_cap_sql( 'post' ) . ' GROUP BY post_author' ) as $row ) { 439 $author_count[ $row->post_author ] = $row->count; 423 440 } 424 441 foreach ( $authors as $author_id ) { … … 429 446 } 430 447 431 $posts = isset( $author_count[ $author->ID] ) ? $author_count[$author->ID] : 0;448 $posts = isset( $author_count[ $author->ID ] ) ? $author_count[ $author->ID ] : 0; 432 449 433 450 if ( ! $posts && $args['hide_empty'] ) { … … 451 468 } 452 469 453 $link = sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', 470 $link = sprintf( 471 '<a href="%1$s" title="%2$s">%3$s</a>', 454 472 get_author_posts_url( $author->ID, $author->user_nicename ), 455 473 /* translators: %s: author's display name */ … … 468 486 $alt = ''; 469 487 if ( ! empty( $args['feed'] ) ) { 470 $alt = ' alt="' . esc_attr( $args['feed'] ) . '"';488 $alt = ' alt="' . esc_attr( $args['feed'] ) . '"'; 471 489 $name = $args['feed']; 472 490 } … … 488 506 489 507 if ( $args['optioncount'] ) { 490 $link .= ' (' . $posts . ')';508 $link .= ' (' . $posts . ')'; 491 509 } 492 510 … … 518 536 519 537 if ( false === ( $is_multi_author = get_transient( 'is_multi_author' ) ) ) { 520 $rows = (array) $wpdb->get_col("SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 2");538 $rows = (array) $wpdb->get_col( "SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 2" ); 521 539 $is_multi_author = 1 < count( $rows ) ? 1 : 0; 522 540 set_transient( 'is_multi_author', $is_multi_author );
Note: See TracChangeset
for help on using the changeset viewer.