Changeset 6365 for trunk/wp-includes/link-template.php
- Timestamp:
- 12/06/2007 07:58:15 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/link-template.php
r6364 r6365 231 231 } 232 232 233 function get_feed_link($feed ='rss2') {233 function get_feed_link($feed = '') { 234 234 global $wp_rewrite; 235 235 … … 241 241 } 242 242 243 if ( 'rss2'== $feed )243 if ( get_default_feed() == $feed ) 244 244 $feed = ''; 245 245 … … 248 248 $output = get_option('home') . user_trailingslashit($permalink, 'feed'); 249 249 } else { 250 if ( empty($feed) ) 251 $feed = get_default_feed(); 252 250 253 if ( false !== strpos($feed, 'comments_') ) 251 254 $feed = str_replace('comments_', 'comments-', $feed); … … 257 260 } 258 261 259 function get_post_comments_feed_link($post_id = '', $feed = ' rss2') {262 function get_post_comments_feed_link($post_id = '', $feed = '') { 260 263 global $id; 261 264 … … 263 266 $post_id = (int) $id; 264 267 268 if ( empty($feed) ) 269 $feed = get_default_feed(); 270 265 271 if ( '' != get_option('permalink_structure') ) { 266 272 $url = trailingslashit( get_permalink($post_id) ) . 'feed'; 267 if ( 'rss2' != $feed)273 if ( $feed != get_default_feed() ) 268 274 $url .= "/$feed"; 269 275 $url = user_trailingslashit($url, 'single_feed'); … … 277 283 278 284 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 */ 301 function 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 309 function 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&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 */ 341 function 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&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 371 function 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&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; 279 398 } 280 399
Note: See TracChangeset
for help on using the changeset viewer.