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
This commit is contained in:
markjaquith 2012-04-07 05:02:45 +00:00
parent 446a67449f
commit a2b1c52214
1 changed files with 8 additions and 1 deletions

View File

@ -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' );