From a2b1c52214445af936e7a5d3e06ce79b01bff50a Mon Sep 17 00:00:00 2001 From: markjaquith Date: Sat, 7 Apr 2012 05:02:45 +0000 Subject: [PATCH] Fix a bunch of individual post comments feeds canonical redirects. Fixes three unit tests. fixes #20384 git-svn-id: http://svn.automattic.com/wordpress/trunk@20396 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/canonical.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/wp-includes/canonical.php b/wp-includes/canonical.php index f098dae771..ce5c8bfeb7 100644 --- a/wp-includes/canonical.php +++ b/wp-includes/canonical.php @@ -66,6 +66,13 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { if ( !isset($redirect['query']) ) $redirect['query'] = ''; + if ( is_feed() && ( $id = get_query_var( 'p' ) ) ) { + if ( $redirect_url = get_post_comments_feed_link( $id, get_query_var( 'feed' ) ) ) { + $redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type', 'feed'), $redirect_url ); + $redirect['path'] = parse_url( $redirect_url, PHP_URL_PATH ); + } + } + if ( is_singular() && 1 > $wp_query->post_count && ($id = get_query_var('p')) ) { $vars = $wpdb->get_results( $wpdb->prepare("SELECT post_type, post_parent FROM $wpdb->posts WHERE ID = %d", $id) ); @@ -219,7 +226,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { $addl_path = ''; if ( is_feed() && in_array( get_query_var('feed'), $wp_rewrite->feeds ) ) { $addl_path = !empty( $addl_path ) ? trailingslashit($addl_path) : ''; - if ( get_query_var( 'withcomments' ) ) + if ( !is_singular() && get_query_var( 'withcomments' ) ) $addl_path .= 'comments/'; if ( ( 'rss' == get_default_feed() && 'feed' == get_query_var('feed') ) || 'rss' == get_query_var('feed') ) $addl_path .= user_trailingslashit( 'feed/' . ( ( get_default_feed() == 'rss2' ) ? '' : 'rss2' ), 'feed' );