From aed909838169c459f396ae735ce49bf69f230a40 Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 24 May 2011 15:49:02 +0000 Subject: [PATCH] Don't do a canonical redirect from author=x to /author/foo/ if the user is not an author git-svn-id: http://svn.automattic.com/wordpress/branches/3.1@18015 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/canonical.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wp-includes/canonical.php b/wp-includes/canonical.php index d111514df7..9d66856c8b 100644 --- a/wp-includes/canonical.php +++ b/wp-includes/canonical.php @@ -141,8 +141,10 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { $redirect['query'] = remove_query_arg('year', $redirect['query']); } elseif ( is_author() && !empty($_GET['author']) && preg_match( '|^[0-9]+$|', $_GET['author'] ) ) { $author = get_userdata(get_query_var('author')); - if ( false !== $author && $redirect_url = get_author_posts_url($author->ID, $author->user_nicename) ) - $redirect['query'] = remove_query_arg('author', $redirect['query']); + if ( ( false !== $author ) && $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_author = %d AND $wpdb->posts.post_status = 'publish' LIMIT 1", $author->ID ) ) ) { + if ( $redirect_url = get_author_posts_url($author->ID, $author->user_nicename) ) + $redirect['query'] = remove_query_arg('author', $redirect['query']); + } } elseif ( is_category() || is_tag() || is_tax() ) { // Terms (Tags/categories) $term_count = 0;