Correct use of get_queried_object() for author archives.

The ->data object (used previously) stores the author data, but the WP_User class has the __get magic method that grants access to that data, so using get_queried_object() without ->data is correct, and compatible with 3.2, which does not use magic methods. Also url-escapes get_author_posts_url.
This commit is contained in:
Konstantin Kovshenin 2012-08-27 10:56:36 +04:00
parent dec5c61928
commit 103ae2cdf6
1 changed files with 2 additions and 2 deletions

View File

@ -26,8 +26,8 @@ get_header(); ?>
} elseif ( is_author() ) { } elseif ( is_author() ) {
// Get the queried author data. // Get the queried author data.
$author = get_queried_object()->data; $author = get_queried_object();
printf( __( 'Author Archives: %s', '_s' ), '<span class="vcard"><a class="url fn n" href="' . get_author_posts_url( $author->ID ) . '" title="' . esc_attr( $author->display_name ) . '" rel="me">' . esc_html( $author->display_name ) . '</a></span>' ); printf( __( 'Author Archives: %s', '_s' ), '<span class="vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( $author->ID ) ) . '" title="' . esc_attr( $author->display_name ) . '" rel="me">' . esc_html( $author->display_name ) . '</a></span>' );
} elseif ( is_day() ) { } elseif ( is_day() ) {
printf( __( 'Daily Archives: %s', '_s' ), '<span>' . get_the_date() . '</span>' ); printf( __( 'Daily Archives: %s', '_s' ), '<span>' . get_the_date() . '</span>' );