Make WordPress Core

Changeset 6365


Ignore:
Timestamp:
12/06/2007 07:58:15 PM (17 years ago)
Author:
ryan
Message:

New feed_link functions. Deprecate rss_link functions. Make default feed pluggable. Props rubys. see #5328

Location:
trunk/wp-includes
Files:
7 edited

Legend:

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

    r6364 r6365  
    367367        'optioncount' => false, 'exclude_admin' => true,
    368368        'show_fullname' => false, 'hide_empty' => true,
    369         'feed' => '', 'feed_image' => '', 'echo' => true
     369        'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true
    370370    );
    371371
  • trunk/wp-includes/category-template.php

    r6364 r6365  
    248248        'style' => 'list', 'show_count' => 0,
    249249        'hide_empty' => 1, 'use_desc_for_title' => 1,
    250         'child_of' => 0, 'feed' => '',
     250        'child_of' => 0, 'feed' => '', 'feed_type' => '',
    251251        'feed_image' => '', 'exclude' => '',
    252252        'hierarchical' => true, 'title_li' => __('Categories'),
  • trunk/wp-includes/classes.php

    r6320 r6365  
    600600                $link .= '(';
    601601
    602             $link .= '<a href="' . get_category_rss_link( 0, $category->term_id, $category->slug ) . '"';
     602            $link .= '<a href="' . get_category_feed_link($category->term_id, $feed_type) . '"';
    603603
    604604            if ( empty($feed) )
  • trunk/wp-includes/deprecated.php

    r6160 r6365  
    730730}
    731731
     732
     733function comments_rss_link($link_text = 'Comments RSS', $deprecated = '') {
     734    post_comments_feed_link($link_text);
     735}
     736
     737function get_category_rss_link($echo = false, $cat_ID, $deprecated = '') {
     738    $link = get_category_feed_link($cat_ID, $feed = 'rss2');
     739
     740    if ( $echo )
     741        echo $link;
     742    return $link;
     743}
     744
     745function get_author_rss_link($echo = false, $author_id, $deprecated = '') {
     746    $link = get_author_feed_link($author_id);
     747    if ( $echo )
     748        echo $link;
     749    return $link;
     750}
     751
    732752?>
  • trunk/wp-includes/feed.php

    r6364 r6365  
    66}
    77
    8 
    98function bloginfo_rss($show = '') {
    109    echo apply_filters('bloginfo_rss', get_bloginfo_rss($show));
     10}
     11
     12function get_default_feed() {
     13    return apply_filters('default_feed', 'rss2');
    1114}
    1215
     
    8184}
    8285
    83 
    8486function get_comment_author_rss() {
    8587    return apply_filters('comment_author_rss', get_comment_author() );
    8688}
    8789
    88 
    8990function comment_author_rss() {
    9091    echo get_comment_author_rss();
    9192}
    92 
    9393
    9494function comment_text_rss() {
     
    9898}
    9999
    100 
    101 function comments_rss_link($link_text = 'Comments RSS', $deprecated = '') {
    102     $url = get_post_comments_feed_link();
    103     echo "<a href='$url'>$link_text</a>";
    104 }
    105 
    106 
    107100function comments_rss($deprecated = '') {
    108101    return get_post_comments_feed_link();
    109102}
    110 
    111 
    112 function get_author_rss_link($echo = false, $author_id, $author_nicename) {
    113     $author_id = (int) $author_id;
    114     $permalink_structure = get_option('permalink_structure');
    115 
    116     if ( '' == $permalink_structure ) {
    117         $link = get_option('home') . '?feed=rss2&amp;author=' . $author_id;
    118     } else {
    119         $link = get_author_posts_url($author_id, $author_nicename);
    120         $link = trailingslashit($link) . user_trailingslashit('feed', 'feed');
    121     }
    122 
    123     $link = apply_filters('author_feed_link', $link);
    124 
    125     if ( $echo )
    126         echo $link;
    127     return $link;
    128 }
    129 
    130 /** get_category_feed_link() - Get the feed link for a given category
    131  *
    132  * Returns a link to the feed for all post in a given category.  A specific feed can be requested
    133  * or left blank to get the default feed.
    134  *
    135  * @package WordPress
    136  * @subpackage Feed
    137  * @since 2.4
    138  *
    139  * @param int $cat_id ID of a category
    140  * @param string $feed Feed type
    141  * @return string Link to the feed for the category specified by $cat_id
    142 */
    143 function get_category_feed_link($cat_id, $feed = 'rss2') {
    144     $cat_id = (int) $cat_id;
    145    
    146     $category = get_category($cat_id);
    147    
    148     if ( empty($category) || is_wp_error($category) )
    149         return false;
    150    
    151     $permalink_structure = get_option('permalink_structure');
    152 
    153     if ( '' == $permalink_structure ) {
    154         $link = get_option('home') . "?feed=$feed&amp;cat=" . $cat_id;
    155     } else {
    156         $link = get_category_link($cat_id);
    157         if( 'rss2' == $feed )
    158             $feed_link = 'feed';
    159         else
    160             $feed_link = "feed/$feed";
    161        
    162         $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed');
    163     }
    164 
    165     $link = apply_filters('category_feed_link', $link, $feed);
    166    
    167     return $link;
    168 }
    169 
    170 
    171 function get_category_rss_link($echo = false, $cat_ID, $deprecated = '') {
    172     $link = get_category_feed_link($cat_ID, 'rss2');
    173 
    174     if ( $echo )
    175         echo $link;
    176     return $link;
    177 }
    178 
    179103
    180104function get_the_category_rss($type = 'rss') {
     
    210134}
    211135
    212 
    213136function the_category_rss($type = 'rss') {
    214137    echo get_the_category_rss($type);
    215 }
    216 
    217 function get_tag_feed_link($tag_id, $feed = 'rss2') {
    218     $tag_id = (int) $tag_id;
    219 
    220     $tag = get_tag($tag_id);
    221 
    222     if ( empty($tag) || is_wp_error($tag) )
    223         return false;
    224 
    225     $permalink_structure = get_option('permalink_structure');
    226 
    227     if ( '' == $permalink_structure ) {
    228         $link = get_option('home') . "?feed=$feed&amp;tag=" . $tag->slug;
    229     } else {
    230         $link = get_tag_link($tag->term_id);
    231         if ( 'rss2' == $feed )
    232             $feed_link = 'feed';
    233         else
    234             $feed_link = "feed/$feed";
    235         $link = $link . user_trailingslashit($feed_link, 'feed');
    236     }
    237 
    238     $link = apply_filters('tag_feed_link', $link, $feed);
    239 
    240     return $link;
    241138}
    242139
  • trunk/wp-includes/functions.php

    r6364 r6365  
    864864
    865865    if ( $feed == '' || $feed == 'feed' )
    866         $feed = 'rss2';
     866        $feed = get_default_feed();
    867867
    868868    $hook = 'do_feed_' . $feed;
  • trunk/wp-includes/link-template.php

    r6364 r6365  
    231231}
    232232
    233 function get_feed_link($feed='rss2') {
     233function get_feed_link($feed = '') {
    234234    global $wp_rewrite;
    235235
     
    241241        }
    242242
    243         if ( 'rss2' == $feed )
     243        if ( get_default_feed() == $feed )
    244244            $feed = '';
    245245
     
    248248        $output =  get_option('home') . user_trailingslashit($permalink, 'feed');
    249249    } else {
     250        if ( empty($feed) )
     251            $feed = get_default_feed();
     252
    250253        if ( false !== strpos($feed, 'comments_') )
    251254            $feed = str_replace('comments_', 'comments-', $feed);
     
    257260}
    258261
    259 function get_post_comments_feed_link($post_id = '', $feed = 'rss2') {
     262function get_post_comments_feed_link($post_id = '', $feed = '') {
    260263    global $id;
    261264
     
    263266        $post_id = (int) $id;
    264267
     268    if ( empty($feed) )
     269        $feed = get_default_feed();
     270
    265271    if ( '' != get_option('permalink_structure') ) {
    266272        $url = trailingslashit( get_permalink($post_id) ) . 'feed';
    267         if ( 'rss2' != $feed )
     273        if ( $feed != get_default_feed() )
    268274            $url .= "/$feed";
    269275        $url = user_trailingslashit($url, 'single_feed');
     
    277283
    278284    return apply_filters('post_comments_feed_link', $url);
     285}
     286
     287/** post_comments_feed_link() - Output the comment feed link for a post.
     288 *
     289 * Prints out the comment feed link for a post.  Link text is placed in the
     290 * anchor.  If no link text is specified, default text is used.  If no post ID
     291 * is specified, the current post is used.
     292 *
     293 * @package WordPress
     294 * @subpackage Feed
     295 * @since 2.4
     296 *
     297 * @param string Descriptive text
     298 * @param int Optional post ID.  Default to current post.
     299 * @return string Link to the comment feed for the current post
     300*/
     301function post_comments_feed_link( $link_text = '', $post_id = '', $feed = '' ) {
     302    $url = get_post_comments_feed_link($post_id, $feed);
     303    if ( empty($link_text) )
     304        $link_text = __('Comments Feed');
     305
     306    echo "<a href='$url'>$link_text</a>";
     307}
     308
     309function get_author_feed_link( $author_id, $feed = '' ) {
     310    $author_id = (int) $author_id;
     311    $permalink_structure = get_option('permalink_structure');
     312
     313    if ( empty($feed) )
     314        $feed = get_default_feed();
     315
     316    if ( '' == $permalink_structure ) {
     317        $link = get_option('home') . '?feed=rss2&amp;author=' . $author_id;
     318    } else {
     319        $link = get_author_posts_url($author_id, $author_nicename);
     320        $link = trailingslashit($link) . user_trailingslashit('feed', 'feed');
     321    }
     322
     323    $link = apply_filters('author_feed_link', $link);
     324
     325    return $link;
     326}
     327
     328/** get_category_feed_link() - Get the feed link for a given category
     329 *
     330 * Returns a link to the feed for all post in a given category.  A specific feed can be requested
     331 * or left blank to get the default feed.
     332 *
     333 * @package WordPress
     334 * @subpackage Feed
     335 * @since 2.4
     336 *
     337 * @param int $cat_id ID of a category
     338 * @param string $feed Feed type
     339 * @return string Link to the feed for the category specified by $cat_id
     340*/
     341function get_category_feed_link($cat_id, $feed = '') {
     342    $cat_id = (int) $cat_id;
     343   
     344    $category = get_category($cat_id);
     345   
     346    if ( empty($category) || is_wp_error($category) )
     347        return false;
     348
     349    if ( empty($feed) )
     350        $feed = get_default_feed();
     351
     352    $permalink_structure = get_option('permalink_structure');
     353
     354    if ( '' == $permalink_structure ) {
     355        $link = get_option('home') . "?feed=$feed&amp;cat=" . $cat_id;
     356    } else {
     357        $link = get_category_link($cat_id);
     358        if( $feed == get_default_feed() )
     359            $feed_link = 'feed';
     360        else
     361            $feed_link = "feed/$feed";
     362       
     363        $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed');
     364    }
     365
     366    $link = apply_filters('category_feed_link', $link, $feed);
     367   
     368    return $link;
     369}
     370
     371function get_tag_feed_link($tag_id, $feed = '') {
     372    $tag_id = (int) $tag_id;
     373
     374    $tag = get_tag($tag_id);
     375
     376    if ( empty($tag) || is_wp_error($tag) )
     377        return false;
     378
     379    $permalink_structure = get_option('permalink_structure');
     380
     381    if ( empty($feed) )
     382        $feed = get_default_feed();
     383
     384    if ( '' == $permalink_structure ) {
     385        $link = get_option('home') . "?feed=$feed&amp;tag=" . $tag->slug;
     386    } else {
     387        $link = get_tag_link($tag->term_id);
     388        if ( $feed == get_default_feed() )
     389            $feed_link = 'feed';
     390        else
     391            $feed_link = "feed/$feed";
     392        $link = $link . user_trailingslashit($feed_link, 'feed');
     393    }
     394
     395    $link = apply_filters('tag_feed_link', $link, $feed);
     396
     397    return $link;
    279398}
    280399
Note: See TracChangeset for help on using the changeset viewer.