WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/07/2009 09:34:01 PM (12 years ago)
Author:
azaozz
Message:

feed_links_extra() DRY, props scribu, fixes #9291

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/general-template.php

    r10708 r10741  
    14451445    if ( is_single() || is_page() ) {
    14461446        $post = &get_post( $id = 0 );
    1447         if ( comments_open() || pings_open() || $post->comment_count > 0 )
    1448             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";
    1449     }
    1450 
    1451     elseif ( is_category() ) {
     1447
     1448        if ( comments_open() || pings_open() || $post->comment_count > 0 ) {
     1449            $title = attribute_escape(sprintf( $args['singletitle'], get_bloginfo('name'), $args['seperator'], wp_specialchars( get_the_title() ) ));
     1450            $href = get_post_comments_feed_link( $post->ID );
     1451        }
     1452    } elseif ( is_category() ) {
    14521453        $cat_id = intval( get_query_var('cat') );
    1453         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";
    1454     }
    1455 
    1456     elseif ( is_tag() ) {
     1454
     1455        $title = attribute_escape(sprintf( $args['cattitle'], get_bloginfo('name'), $args['seperator'], get_cat_name( $cat_id ) ));
     1456        $href = get_category_feed_link( $cat_id );
     1457    } elseif ( is_tag() ) {
    14571458        $tag_id = intval( get_query_var('tag_id') );
    14581459        $tag = get_tag( $tag_id );
    1459         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";
    1460     }
    1461 
    1462     elseif ( is_author() ) {
     1460
     1461        $title = attribute_escape(sprintf( $args['tagtitle'], get_bloginfo('name'), $args['seperator'], $tag->name ));
     1462        $href = get_tag_feed_link( $tag_id );
     1463    } elseif ( is_author() ) {
    14631464        $author_id = intval( get_query_var('author') );
    1464         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";
    1465     }
    1466 
    1467     elseif ( is_search() ) {
    1468         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";
    1469     }
     1465
     1466        $title = attribute_escape(sprintf( $args['authortitle'], get_bloginfo('name'), $args['seperator'], get_author_name( $author_id ) ));
     1467        $href = get_author_feed_link( $author_id );
     1468    } elseif ( is_search() ) {
     1469        $title = attribute_escape(sprintf( $args['searchtitle'], get_bloginfo('name'), $args['seperator'], get_search_query() ));
     1470        $href = get_search_feed_link();
     1471    }
     1472
     1473    if ( isset($title) && isset($href) )
     1474        echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . $title . '" href="' . $href . '" />' . "\n";
    14701475}
    14711476
Note: See TracChangeset for help on using the changeset viewer.