From f166e119f344c5bb2b19297e77ebc4295a3b3718 Mon Sep 17 00:00:00 2001 From: ryan Date: Sun, 22 May 2011 23:18:06 +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/trunk@17991 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 af64d9606a..98c3794d4b 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;