Ticket #5173: getcatfeedlink.diff

File getcatfeedlink.diff, 1.4 KB (added by ionfish, 5 years ago)
  • wp-includes/feed.php

     
    128128} 
    129129 
    130130 
    131 function get_category_rss_link($echo = false, $cat_ID, $category_nicename) { 
     131function get_category_feed_link($cat_id, $feed = 'rss2') { 
     132        $cat_id = (int) $cat_id; 
     133         
     134        $category = get_category($cat_id); 
     135         
     136        if ( empty($category) || is_wp_error($category) ) 
     137                return false; 
     138         
    132139        $permalink_structure = get_option('permalink_structure'); 
    133140 
    134141        if ( '' == $permalink_structure ) { 
    135                 $link = get_option('home') . '?feed=rss2&cat=' . $cat_ID; 
     142                $link = get_option('home') . "?feed=$feed&cat=" . $cat_id; 
    136143        } else { 
    137                 $link = get_category_link($cat_ID); 
    138                 $link = trailingslashit($link) . user_trailingslashit('feed', 'feed'); 
     144                $link = get_category_link($cat_id); 
     145                if( 'rss2' == $feed ) 
     146                        $feed_link = 'feed'; 
     147                else 
     148                        $feed_link = "feed/$feed"; 
     149                 
     150                $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed'); 
    139151        } 
    140152 
    141         $link = apply_filters('category_feed_link', $link); 
     153        $link = apply_filters('category_feed_link', $link, $feed); 
     154         
     155        return $link; 
     156} 
    142157 
     158 
     159function get_category_rss_link($echo = false, $cat_ID, $category_nicename) { 
     160        $link = get_category_feed_link($cat_ID, $feed = 'rss2'); 
     161 
    143162        if ( $echo ) 
    144163                echo $link; 
    145164        return $link;