feed_links_extra() DRY, props scribu, fixes #9291

git-svn-id: http://svn.automattic.com/wordpress/trunk@10741 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2009-03-07 21:34:01 +00:00
parent 957fa2e686
commit 2416f426d9
1 changed files with 19 additions and 14 deletions

View File

@ -1444,29 +1444,34 @@ function feed_links_extra( $args ) {
if ( is_single() || is_page() ) { if ( is_single() || is_page() ) {
$post = &get_post( $id = 0 ); $post = &get_post( $id = 0 );
if ( comments_open() || pings_open() || $post->comment_count > 0 )
echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . attribute_escape(sprintf( $args['singletitle'], get_bloginfo('name'), $args['seperator'], wp_specialchars( get_the_title() ) )) . '" href="' . get_post_comments_feed_link( $post->ID ) . "\" />\n";
}
elseif ( is_category() ) { if ( comments_open() || pings_open() || $post->comment_count > 0 ) {
$title = attribute_escape(sprintf( $args['singletitle'], get_bloginfo('name'), $args['seperator'], wp_specialchars( get_the_title() ) ));
$href = get_post_comments_feed_link( $post->ID );
}
} elseif ( is_category() ) {
$cat_id = intval( get_query_var('cat') ); $cat_id = intval( get_query_var('cat') );
echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . attribute_escape(sprintf( $args['cattitle'], get_bloginfo('name'), $args['seperator'], get_cat_name( $cat_id ) )) . '" href="' . get_category_feed_link( $cat_id ) . "\" />\n";
}
elseif ( is_tag() ) { $title = attribute_escape(sprintf( $args['cattitle'], get_bloginfo('name'), $args['seperator'], get_cat_name( $cat_id ) ));
$href = get_category_feed_link( $cat_id );
} elseif ( is_tag() ) {
$tag_id = intval( get_query_var('tag_id') ); $tag_id = intval( get_query_var('tag_id') );
$tag = get_tag( $tag_id ); $tag = get_tag( $tag_id );
echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . attribute_escape(sprintf( $args['tagtitle'], get_bloginfo('name'), $args['seperator'], $tag->name )) . '" href="' . get_tag_feed_link( $tag_id ) . "\" />\n";
}
elseif ( is_author() ) { $title = attribute_escape(sprintf( $args['tagtitle'], get_bloginfo('name'), $args['seperator'], $tag->name ));
$href = get_tag_feed_link( $tag_id );
} elseif ( is_author() ) {
$author_id = intval( get_query_var('author') ); $author_id = intval( get_query_var('author') );
echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . attribute_escape(sprintf( $args['authortitle'], get_bloginfo('name'), $args['seperator'], get_author_name( $author_id ) )) . '" href="' . get_author_feed_link( $author_id ) . "\" />\n";
$title = attribute_escape(sprintf( $args['authortitle'], get_bloginfo('name'), $args['seperator'], get_author_name( $author_id ) ));
$href = get_author_feed_link( $author_id );
} elseif ( is_search() ) {
$title = attribute_escape(sprintf( $args['searchtitle'], get_bloginfo('name'), $args['seperator'], get_search_query() ));
$href = get_search_feed_link();
} }
elseif ( is_search() ) { if ( isset($title) && isset($href) )
echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . attribute_escape(sprintf( $args['searchtitle'], get_bloginfo('name'), $args['seperator'], get_search_query() )) . '" href="' . get_search_feed_link() . "\" />\n"; echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . $title . '" href="' . $href . '" />' . "\n";
}
} }
/** /**