Ticket #5328: default_feed.diff
| File default_feed.diff, 11.7 kB (added by ryan, 8 months ago) |
|---|
-
wp-includes/link-template.php
old new 226 226 } 227 227 } 228 228 229 function get_feed_link($feed ='rss2') {229 function get_feed_link($feed = '') { 230 230 global $wp_rewrite; 231 231 $do_perma = 0; 232 232 $feed_url = get_option('siteurl'); … … 239 239 $permalink = $wp_rewrite->get_comment_feed_permastruct(); 240 240 } 241 241 242 if ( 'rss2'== $feed )242 if ( get_default_feed() == $feed ) 243 243 $feed = ''; 244 244 245 245 $permalink = str_replace('%feed%', $feed, $permalink); 246 246 $permalink = preg_replace('#/+#', '/', "/$permalink"); 247 247 $output = get_option('home') . user_trailingslashit($permalink, 'feed'); 248 248 } else { 249 if ( empty($feed) ) 250 $feed = get_default_feed(); 251 249 252 if ( false !== strpos($feed, 'comments_') ) 250 253 $feed = str_replace('comments_', 'comments-', $feed); 251 254 … … 255 258 return apply_filters('feed_link', $output, $feed); 256 259 } 257 260 258 function get_post_comments_feed_link($post_id = '', $feed = ' rss2') {261 function get_post_comments_feed_link($post_id = '', $feed = '') { 259 262 global $id; 260 263 261 264 if ( empty($post_id) ) 262 265 $post_id = (int) $id; 263 266 267 if ( empty($feed) ) 268 $feed = get_default_feed(); 269 264 270 if ( '' != get_option('permalink_structure') ) { 265 271 $url = trailingslashit( get_permalink($post_id) ) . 'feed'; 266 if ( 'rss2' != $feed)272 if ( $feed != get_default_feed() ) 267 273 $url .= "/$feed"; 268 274 $url = user_trailingslashit($url, 'single_feed'); 269 275 } else { … … 277 283 return apply_filters('post_comments_feed_link', $url); 278 284 } 279 285 286 /** post_comments_feed_link() - Output the comment feed link for a post. 287 * 288 * Prints out the comment feed link for a post. Link text is placed in the 289 * anchor. If no link text is specified, default text is used. If no post ID 290 * is specified, the current post is used. 291 * 292 * @package WordPress 293 * @subpackage Feed 294 * @since 2.4 295 * 296 * @param string Descriptive text 297 * @param int Optional post ID. Default to current post. 298 * @return string Link to the comment feed for the current post 299 */ 300 function post_comments_feed_link( $link_text = '', $post_id = '', $feed = '' ) { 301 $url = get_post_comments_feed_link($post_id, $feed); 302 if ( empty($link_text) ) 303 $link_text = __('Comments Feed'); 304 305 echo "<a href='$url'>$link_text</a>"; 306 } 307 308 function get_author_feed_link( $author_id, $feed = '' ) { 309 $author_id = (int) $author_id; 310 $permalink_structure = get_option('permalink_structure'); 311 312 if ( empty($feed) ) 313 $feed = get_default_feed(); 314 315 if ( '' == $permalink_structure ) { 316 $link = get_option('home') . '?feed=rss2&author=' . $author_id; 317 } else { 318 $link = get_author_posts_url($author_id, $author_nicename); 319 $link = trailingslashit($link) . user_trailingslashit('feed', 'feed'); 320 } 321 322 $link = apply_filters('author_feed_link', $link); 323 324 return $link; 325 } 326 327 /** get_category_feed_link() - Get the feed link for a given category 328 * 329 * Returns a link to the feed for all post in a given category. A specific feed can be requested 330 * or left blank to get the default feed. 331 * 332 * @package WordPress 333 * @subpackage Feed 334 * @since 2.4 335 * 336 * @param int $cat_id ID of a category 337 * @param string $feed Feed type 338 * @return string Link to the feed for the category specified by $cat_id 339 */ 340 function get_category_feed_link($cat_id, $feed = '') { 341 $cat_id = (int) $cat_id; 342 343 $category = get_category($cat_id); 344 345 if ( empty($category) || is_wp_error($category) ) 346 return false; 347 348 if ( empty($feed) ) 349 $feed = get_default_feed(); 350 351 $permalink_structure = get_option('permalink_structure'); 352 353 if ( '' == $permalink_structure ) { 354 $link = get_option('home') . "?feed=$feed&cat=" . $cat_id; 355 } else { 356 $link = get_category_link($cat_id); 357 if( $feed == get_default_feed() ) 358 $feed_link = 'feed'; 359 else 360 $feed_link = "feed/$feed"; 361 362 $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed'); 363 } 364 365 $link = apply_filters('category_feed_link', $link, $feed); 366 367 return $link; 368 } 369 370 function get_tag_feed_link($tag_id, $feed = '') { 371 $tag_id = (int) $tag_id; 372 373 $tag = get_tag($tag_id); 374 375 if ( empty($tag) || is_wp_error($tag) ) 376 return false; 377 378 $permalink_structure = get_option('permalink_structure'); 379 380 if ( empty($feed) ) 381 $feed = get_default_feed(); 382 383 if ( '' == $permalink_structure ) { 384 $link = get_option('home') . "?feed=$feed&tag=" . $tag->slug; 385 } else { 386 $link = get_tag_link($tag->term_id); 387 if ( $feed == get_default_feed() ) 388 $feed_link = 'feed'; 389 else 390 $feed_link = "feed/$feed"; 391 $link = $link . user_trailingslashit($feed_link, 'feed'); 392 } 393 394 $link = apply_filters('tag_feed_link', $link, $feed); 395 396 return $link; 397 } 398 280 399 function get_edit_post_link( $id = 0 ) { 281 400 $post = &get_post( $id ); 282 401 -
wp-includes/author-template.php
old new 366 366 $defaults = array( 367 367 'optioncount' => false, 'exclude_admin' => true, 368 368 'show_fullname' => false, 'hide_empty' => true, 369 'feed' => '', 'feed_image' => '', ' echo' => true369 'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true 370 370 ); 371 371 372 372 $r = wp_parse_args( $args, $defaults ); -
wp-includes/classes.php
old new 599 599 if ( empty($feed_image) ) 600 600 $link .= '('; 601 601 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) . '"'; 603 603 604 604 if ( empty($feed) ) 605 605 $alt = ' alt="' . sprintf(__( 'Feed for all posts filed under %s' ), $cat_name ) . '"'; -
wp-includes/deprecated.php
old new 729 729 return $cat->name; 730 730 } 731 731 732 733 function comments_rss_link($link_text = 'Comments RSS', $commentsrssfilename = 'nolongerused') { 734 post_comments_feed_link($link_text); 735 } 736 737 function get_category_rss_link($echo = false, $cat_ID, $category_nicename) { 738 $link = get_category_feed_link($cat_ID, $feed = 'rss2'); 739 740 if ( $echo ) 741 echo $link; 742 return $link; 743 } 744 745 function get_author_rss_link($echo = false, $author_id, $author_nicename) { 746 $link = get_author_feed_link($author_id); 747 if ( $echo ) 748 echo $link; 749 return $link; 750 } 751 732 752 ?> -
wp-includes/feed.php
old new 5 5 return apply_filters('get_bloginfo_rss', convert_chars($info)); 6 6 } 7 7 8 9 8 function bloginfo_rss($show = '') { 10 9 echo apply_filters('bloginfo_rss', get_bloginfo_rss($show)); 11 10 } 12 11 12 function get_default_feed() { 13 return apply_filters('default_feed', 'rss2'); 14 } 15 13 16 function get_wp_title_rss($sep = '»') { 14 17 $title = wp_title($sep, false); 15 18 if ( is_wp_error( $title ) ) … … 97 100 echo $comment_text; 98 101 } 99 102 100 101 function comments_rss_link($link_text = 'Comments RSS', $commentsrssfilename = 'nolongerused') {102 $url = get_post_comments_feed_link();103 echo "<a href='$url'>$link_text</a>";104 }105 106 107 103 function comments_rss($commentsrssfilename = 'nolongerused') { 108 104 return get_post_comments_feed_link(); 109 105 } 110 106 111 112 function get_author_rss_link($echo = false, $author_id, $author_nicename) {113 $auth_ID = (int) $author_id;114 $permalink_structure = get_option('permalink_structure');115 116 if ( '' == $permalink_structure ) {117 $link = get_option('home') . '?feed=rss2&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 category131 *132 * Returns a link to the feed for all post in a given category. A specific feed can be requested133 * or left blank to get the default feed.134 *135 * @package WordPress136 * @subpackage Feed137 * @since 2.4138 *139 * @param int $cat_id ID of a category140 * @param string $feed Feed type141 * @return string Link to the feed for the category specified by $cat_id142 */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&cat=" . $cat_id;155 } else {156 $link = get_category_link($cat_id);157 if( 'rss2' == $feed )158 $feed_link = 'feed';159 else160 $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, $category_nicename) {172 $link = get_category_feed_link($cat_ID, $feed = 'rss2');173 174 if ( $echo )175 echo $link;176 return $link;177 }178 179 180 107 function get_the_category_rss($type = 'rss') { 181 108 $categories = get_the_category(); 182 109 $tags = get_the_tags(); … … 215 142 echo get_the_category_rss($type); 216 143 } 217 144 218 function get_tag_feed_link($tag_id, $feed = 'rss2') {219 $tag_id = (int) $tag_id;220 221 $tag = get_tag($tag_id);222 223 if ( empty($tag) || is_wp_error($tag) )224 return false;225 226 $permalink_structure = get_option('permalink_structure');227 228 if ( '' == $permalink_structure ) {229 $link = get_option('home') . "?feed=$feed&tag=" . $tag->slug;230 } else {231 $link = get_tag_link($tag->term_id);232 if ( 'rss2' == $feed )233 $feed_link = 'feed';234 else235 $feed_link = "feed/$feed";236 $link = $link . user_trailingslashit($feed_link, 'feed');237 }238 239 $link = apply_filters('tag_feed_link', $link, $feed);240 241 return $link;242 }243 244 145 function html_type_rss() { 245 146 $type = get_bloginfo('html_type'); 246 147 if (strpos($type, 'xhtml') !== false) -
wp-includes/functions.php
old new 861 861 $feed = preg_replace( '/^_+/', '', $feed ); 862 862 863 863 if ( $feed == '' || $feed == 'feed' ) 864 $feed = 'rss2';864 $feed = get_default_feed(); 865 865 866 866 $hook = 'do_feed_' . $feed; 867 867 do_action( $hook, $wp_query->is_comment_feed ); -
wp-includes/category-template.php
old new 247 247 'order' => 'ASC', 'show_last_update' => 0, 248 248 'style' => 'list', 'show_count' => 0, 249 249 'hide_empty' => 1, 'use_desc_for_title' => 1, 250 'child_of' => 0, 'feed' => '', 250 'child_of' => 0, 'feed' => '', 'feed_type' => '', 251 251 'feed_image' => '', 'exclude' => '', 252 252 'hierarchical' => true, 'title_li' => __('Categories'), 253 253 'echo' => 1 -
wp-content/themes/default/sidebar.php
old new 51 51 </ul> 52 52 </li> 53 53 54 <?php wp_list_categories('show_count=1& title_li=<h2>Categories</h2>'); ?>54 <?php wp_list_categories('show_count=1&feed=Atom&feed_type=atom&title_li=<h2>Categories</h2>'); ?> 55 55 56 56 <?php /* If this is the frontpage */ if ( is_home() || is_page() ) { ?> 57 57 <?php wp_list_bookmarks(); ?>
